- Home /
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??
Answer by sriram90 · Dec 31, 2010 at 06:03 AM
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...
Answer by Justin Warner · Dec 30, 2010 at 04:46 PM
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!
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.
Your answer
Follow this Question
Related Questions
Pause and resume coroutine 0 Answers
Pause and resume coroutine 1 Answer
My Unity Android app is preventing the lock screen from displaying properly 2 Answers
Yield WaitForSeconds Not Working. Coroutine. 1 Answer
Unpausing While Keeping Values 0 Answers