Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by OrionGamesInc · Feb 15, 2016 at 05:59 PM · javascriptbuttonmenubooleanbooleans

How do I create a static bool?

I have a menu screen with three buttons, start night one (intractable), start night two (disabled until bool is TRUE), and quit (intractable). I simply want, after the player finishes the game (after 530 seconds) set the bool to TRUE and redirect the player back to the menu, where then they can continue and play night two because it will be enabled from the bool.

There are a few things I have no idea how to do:
- Create the static bool, and have it become true after 530 seconds
- Have the night two button use the bool to determine enabled/disabled state
- Redirect player to menu after 530 seconds

Please and thanks for any help! Please use javascript.

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 OrionGamesInc · Feb 16, 2016 at 12:42 AM 0
Share

I was able to get the night 2 button to activate after the night 1 button is pressed. How do I get the player to go back to the menu in the same session after 530 seconds? Thanks

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by EmHuynh · Feb 16, 2016 at 01:55 AM

Hello, @LeoKane. Nicely done, you took care of those buttons. Here are some codes to help you get an idea of what you could do to achieve your goal (for your menu).

     // The flag to ensure we only attempt to the load the menu once.
     bool menuCoroutineStarted = false;
     
     // A coroutine to load the menu after waiting for 530 seconds.
     // For testing purposes, that you should lower it so we can
     // quickly test things out.
     IEnumerator BackToTheMenu()
     {
         yield return new WaitForSeconds( 10 );
         // Load the menu scene.
         SceneManager.LoadScene( "Menu", LoadSceneMode.Single );
     }
 
     void Update()
     {
         if( Input.GetKeyUp( KeyCode.Space ) && menuCoroutineStarted == false ) {
             menuCoroutineStarted = true;
             // Call StartCoroutine to start BackToTheMenu.
             StartCoroutine( BackToTheMenu() );
         }
     }
Comment
Add comment · Show 2 · 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 OrionGamesInc · Feb 17, 2016 at 08:44 PM 0
Share

Awesome. I'll try it out C:

avatar image OrionGamesInc · Feb 17, 2016 at 08:49 PM 0
Share

It works mostly. I made it into a javascript, right? But a lot of the script is obsolete. The only two errors though are missing semi-colons, could you help?

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

54 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

Related Questions

Boolean not functioning as intended. 1 Answer

making a pause menu 1 Answer

Disabling random GUI Button from array 0 Answers

How do I make an uninteractable menu button interactable? 1 Answer

With the following script i wanted to activate a collider at the left/right side... 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