- Home /
Question by
Robomaster · Jan 13, 2013 at 10:25 PM ·
guierrorbuttonbox
GUI.Button error
Hello so i what i was trying to do was create a simple code in which when i press a button it would bring up 5 buttons but it doesn't seem to work when i try to test it. Does anyone know why it isn't working? It changes colors correctly but doesn't bring up the buttons. Thanks in advance!
if(button1Clicked)
GUI.color = Color.red;
else
GUI.color = Color.white;
if (GUI.Button(new Rect(400,400,100,20), "Inventory")){{
button1Clicked = true;
button2Clicked = false;
button3Clicked = false;
button4Clicked = false;
}
if (GUI.Button(new Rect(470,440,50,50), "")){}
if (GUI.Button(new Rect(520,440,50,50), "")){}
if (GUI.Button(new Rect(570,440,50,50), "")){}
if (GUI.Button(new Rect(620,440,50,50), "")){}
if (GUI.Button(new Rect(670,440,50,50), "")){}
}
Comment
Best Answer
Answer by robertbu · Jan 14, 2013 at 12:29 AM
GUI.Button() will only return true once per click. Your code will only show the other buttons for a single frame. Try setting a boolean value when the button is clicked and then displaying the other buttons based on the boolean value.