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 ina · Jan 03, 2011 at 01:11 PM · menuonguitogglepopupconditional

If using a conditional-situational menu, such as a pop-up, must wait till next OnGUI?

If you are using a conditional-situational menu... such as a pop-up dialog ("Are you sure you want to quit", etc) that occurs after you click on another gui button ("Quit"), is the only way to create both the toggle-button gui menu and check the conditional to wait until the next OnGUI-call?

In this case, every time you have a dialog like this, you would have to use a global to check for loading the dialog on next onGUI?

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

Answer by cjmarsh · Jan 05, 2011 at 12:43 PM

After clicking the GUI Button "Quit" you could instantiate an empty game object prefab with an attached OnGUI script for the pop-up confirmation. This way you could simply instantiate and destroy the situational code without having it embedded in the overall global call.

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 PrimeDerektive · Jan 05, 2011 at 01:24 PM

You could just use boolean vars to toggle what GUI code you want to show, like this:

private var showQuit : boolean = false;

function OnGUI(){

 if (GUI.Button (Rect (10,10, 100, 50), "Quit Game")) {
     showQuit = true;
 }

 if (showQuit == true){
     GUI.Button(Rect ((Screen.width/2), (Screen.height/2), 100, 50), "Are you sure you want to quit?");
 }

}

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 ina · Jan 10, 2011 at 11:53 PM 0
Share

so... my question is if this is the only way to do such conditional menu's and doesn't it add unnecessary processing since it's checked each frame?

avatar image PrimeDerektive · Jan 11, 2011 at 12:13 AM 0
Share

Every gui element is checked every frame, so adding a bool check is no more cpu intensive than simply adding another gui element... the difference is negligible, if there is one at all. This is the only way I've ever seen it done, unless you want to be instantiating/destroying objects all over the place with different GUI code on them, which is probably intensive even moreso.

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

No one has followed this question yet.

Related Questions

VR popup menu in front of Camera in Fixed Position/Rotation 2 Answers

"Escape" not working to open menu? 1 Answer

Best way to display a (highscore) dialogue 0 Answers

How can i create a popup menu when a button is clicked? 2 Answers

gameTimer needs to be based on an event, not onGUI 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