• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by sriram90 · Dec 30, 2010 at 02:40 PM · coroutinesavepauseresume

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??

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

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...

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

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!

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image sriram90 · Dec 31, 2010 at 06:02 AM 0
Share

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

Hint: You can notify a user about this post by typing @username

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

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Pause and resume coroutine 1 Answer

Pause and resume coroutine 0 Answers

pause animation when two objects is colliding and resume when they're not colliding without rigid body? 0 Answers

Pause game-resume causing event to fire 1 Answer

Can't set Time.timeScale back to 1. 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges