Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 looMeenin · Jul 15, 2014 at 09:04 PM · c#gui

Can I pause parts of a game in Unity?

I have a pause menu that I built in Unity3D, using sprites and colliders. I can't pause the game using something like this:

 if(gameObject == pauseButton)
 {
     Time.timeScale = 0;
 }

because it pauses my pause menu too. I realize I should have built the pause menu with GUI objects so the game can be paused without pausing the GUI menu but I'm wondering if there is an easy workaround. Is it possible to assign pause menu elements to a layer and then enable the layer while the other layers are paused?

Also, is it generally a terrible idea not to use Unity GUI objects when building a gui?

Comment
Add comment · Show 2
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 robertbu · Jul 15, 2014 at 09:25 PM 0
Share

It is unclear why you are having issues. Setting timeScale to zero does not stop Update() calls. So we really need your UI code to understand why you are having issues. If you are using Time.deltaTime to drive things in your UI, you can do something like this:

 var myDeltaTime = Time.realtimeSinceStartup - prevRealTime;
 prevRealTime = Time.realtimeSinceStartup;

Then you use myDeltaTime ins$$anonymous$$d of Time.deltaTime. This code will not pause when you set timeScale = 0.0;

As for the GUI class, lots of folks use it for their UI. The big downside for mobile is that every GUI UI element produces a drawcall, but for something like a menu that appear and is gone, this is not an issue. Third-party UI systems like EZGUI and NGUI use world objects and texture atlases for building UIs. It is rumored that the new UI system to be released in Unity 4.6 will be similar to NGUI.

avatar image looMeenin · Jul 15, 2014 at 09:42 PM 0
Share

$$anonymous$$y pause menu includes lots of animations so that is why I can't set timeScale to zero. I ended up using SetActive(false) on the parent GameObject that holds all pausable objects.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by AndyMartin458 · Jul 15, 2014 at 09:18 PM

I think it might be overly complicated to build the pause GUI in this way. Is there extra functionality that you need other than standard unpause? There are tons of details and answers for what you are trying to do on this post. http://answers.unity3d.com/questions/7544/how-do-i-pause-my-game.html

The easiest option is to set the timeScale to 0 and draw your pause menu with Unity GUI. I know you are trying to avoid that very thing. The other solution is to manually pause all of the MonoBehaviour classes manually when the game is paused.

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

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.

Follow this Question

Answers Answers and Comments

23 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Access clicked button from the different function 1 Answer

Set the position of GUIBox 1 Answer

Error CS1519 1 Answer

Not working gui buttons 1 Answer

Distribute terrain in zones 3 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