- Home /
Another GUI question. enable and disable
Hi All I was looking around for a script to make a gui menu appear and dissapear and found lots with a key press but I was wondering if it was possible to make it so you can enable and disable a gui menu with a gui button?
Like a button that when you press it shows the GUI menu and then when it is open and you press the button again then it will close the menu again?
I have the menu all done with ongui but I have no idea how to make the button ? Please help me
Answer by WillTAtl · Nov 01, 2011 at 04:39 PM
Just add a boolean variable to keep track of the menu state, i.e., isMenuOpen.
When the button that opens/closes it is clicked, toggle this variable's value (isMenuOpen=!isMenuOpen).
Then wrap the code that draws the menu in an conditional, if(isMenuOpen) { draw the menu }
If you also want the menu to close when a button inside the menu is clicked, you can just add "isMenuOpen=false" to that button's code.
Hope this helps!
Your answer
Follow this Question
Related Questions
How do I use my .png file as a button? 1 Answer
My GUI buttons are triggering without user input. 1 Answer
Sound to play when clicking buttons on GUI 1 Answer
Animate GUI Elements 1 Answer
Cube click pop-up menu 0 Answers