x


pause,resume and save coroutines

hi all,

i want to clear answer for to pause,resume and save coroutines (or) gamestate...already i have googled,am i got some information from this link..http://forum.unity3d.com/threads/261...oroutine-state

here i got only the explanation and i want to know how i want to start game again using resume...

if i click "pause" button, i have stop all the coroutines from that state using "StopAllCoroutines"...

but i dunno how to start that means resumes the game again.... can any one give correct way or idea??

i have already tried with "Time.timeScale" its pauses correctly,but when i resumes the game it's resuming very fast..that means game is loading very quickly....how to stop it also??

more ▼

asked Dec 30 '10 at 02:40 PM

sriram90 gravatar image

sriram90
475 33 37 47

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

ya guys finally i got the perfect ans.....i have found in google from "Pause and Coroutine " under the link http://forum.unity3d.com/threads/683...al-pause-state..

its really helpful....just use

while (_myPauseState)
{
yield return new WaitForFixedUpdate();
}

in your coroutines....it'll work fine...thank you guys ... its only for pause and resume your game state...and have to find about save...if any one have idea about save,just post that answer...

more ▼

answered Dec 31 '10 at 06:03 AM

sriram90 gravatar image

sriram90
475 33 37 47

(comments are locked)
10|3000 characters needed characters left

Save the time, and then pause it, then when you need to resume it, make the time equal to that time...

http://www.unifycommunity.com/wiki/index.php?title=PauseMenu

function PauseGame() {
    savedTimeScale = Time.timeScale;
    Time.timeScale = 0;
    AudioListener.pause = true;
    if (pauseFilter) pauseFilter.enabled = true;
    currentPage = Page.Main;
}

function UnPauseGame() {
    Time.timeScale = savedTimeScale;
    AudioListener.pause = false;
    if (pauseFilter) pauseFilter.enabled = false;
    currentPage = Page.None;
    if (IsBeginning() && start != null) {
        start.active = true;
    }
}

Of course take out what you don't need...

Hope this helps!

more ▼

answered Dec 30 '10 at 04:46 PM

Justin Warner gravatar image

Justin Warner
6.3k 19 27 65

hi Justin Warner,its just saying to stop all the thread what is running in your program...i want to stop all the coroutines in the script.

Dec 31 '10 at 06:02 AM sriram90
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x442
x336
x268
x20

asked: Dec 30 '10 at 02:40 PM

Seen: 2544 times

Last Updated: Dec 31 '10 at 04:46 AM