Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 3kWikiGames · May 23, 2018 at 09:01 PM · mobilepauseglitchcontroloptions

[Solved] Restarting scene not automatically playing (pause button?)

When starting the game up, and clicking the start game from the title menu, everything works just fine. Its when from the pause button you go back to the menu, and click start game again that it requires you to push the pause button for the game to resume. Unsure how to get it to start up automatically, like it does the first time the scene is loaded.

Order: 1) Clicks start game alt text

2)Goes to top right button, pause. alt text

screenshot-4.png (180.0 kB)
screenshot-3.png (75.9 kB)
Comment
Add comment · Show 1
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 3kWikiGames · May 23, 2018 at 09:08 PM 0
Share

Here is some of the code:

 public static bool paused = false;

 public void pause()
     {
         paused = !paused;
         Time.timeScale = $$anonymous$$athf.Approximately(Time.timeScale, 0.0f) ? 1.0f : 0.0f;
         leftstick.SetActive(!paused);
         rightstick.SetActive(!paused);
 
         options.SetActive(paused);
     }

I was wondering if it may be related that the level manager script that handles the scenes may require changing the paused bool before switching scenes?

2 Replies

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

Answer by Tobychappell · May 23, 2018 at 09:35 PM

Changed my answer after noticing your comment with the code that you are using.


This fix would depend on what is calling this method and why.

For a quick fix you could introduce an optional nullable Boolean parameter in the method so that when it is true it will change the pause state to paused and flase to unpaused.

     // Booleans initialise as false, 
     // Making it a property in this way restricts access to this. This will help prevent something else messing with the expected outcome of pause() when it is used.
     public static bool IsPaused { get; private set; }

     public void pause(bool? overridePause = null)
     {
       if (overridePause.HasValue)
       {
         IsPaused = overridePause.Value;
       }
       else
       {
         IsPaused = !IsPaused;
       }
       // removed "Mathf.Approximately(Time.timeScale, 0.0f)" as it seems you want the timescale to be 1 or 0 based on the value of 'IsPaused' not the value of the timescale itself.
       Time.timeScale = IsPaused ? 0 : 1;
       leftstick.SetActive(!IsPaused);
       rightstick.SetActive(!IsPaused);

       options.SetActive(IsPaused);
     }



For normal toggling of Pausing:

 pause();

For explicitly pausing the game:

 pause(true);

For explicitly un-pausing the game:

 pause(false);
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 3kWikiGames · May 24, 2018 at 01:26 AM 0
Share

Ended up really cleaning up my code and working finally. Thank you so much! It worked by changing the timescale at the start of the scene to 1 which I didn't think of before.

avatar image
0

Answer by 3kWikiGames · May 23, 2018 at 09:02 PM

3)Goes back to the Title Screen alt text

4) After starting game up again, it shows this screen but paused, requiring another push of the pause button for the game to resume correctly alt text


screenshot-5.png (124.8 kB)
screenshot-6.png (170.3 kB)
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

119 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 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 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 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 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 avatar image avatar image avatar image avatar image

Related Questions

How to make camera position relative to a specific target. 1 Answer

HyperCasual mobil control 0 Answers

Pasue Game and then Ask for input to unpasue 0 Answers

Character Controller Initial Problem With Mobile 0 Answers

Xbox 360 Control GUI problem 0 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