Hello to all. I need help to achieve the following functionality. In my scene there is a gui.button (1) that on click shows/hides a gameobject with a boolean.
There is also another gui.button (2), that on click shows a gui,box with some options menu. Because, the gui.box renders always above every other scene element, I want to have some interactivity between those two buttons.
I want to check when the user has clicked e.g. the gui.button (1) to show the gameobject, not to be able to click the gui.button (2), and vice versa.
Is there an easy way to make this function work in Unity? Thank you all for your answers to noob in scripting .
Ok, this is one of those go and do some tutorials post, but Il try to help you a little.
( 1 ) and ( 2 ) Showing and hiding object with a Gui button and bool. Once you have the gameObject referenced by your gui script you can deactivate it with ( eg ) gameObjName.SetActive( false ); or as an alt you can reference the object’s renderer component to unrender it. Inside of a button a simple bool can be used like a toggle ( eg ) GUI.Button(Rect(0,0,0,0), “” )) { myBool = !myBool; } . // Button toggle Gui can also be opened / closed with a bool used in conditional ( eg ) if(myBool) { GUI.Box(Rect(0,0,0,0), “”); }
( 1 / 2 ) To disable an gui element without hiding it you can use GUI.enabled = false;