- Home /
Make more buttons appear, on button click.
Trying to make a sort of drop down menu, where you click one button, then several others appear below it. But they don't appear for some reason. The debug goes off though.
if(GUI.Button(new Rect (Screen.width/2, Screen.height/3, Screen.width/4, Screen.height/3), shopKeepMenu1))
{
Debug.Log("Clicked button 3");
GUI.Button(new Rect(Screen.width/2,Screen.height/4,Screen.width/4, Screen.height/3),testTexture1);
GUI.Button(new Rect(Screen.width/2,Screen.height/5,Screen.width/4, Screen.height/3),testTexture1);
GUI.Button(new Rect(Screen.width/2,Screen.height/6,Screen.width/4, Screen.height/3),testTexture1);
}
Comment
I believe you need an if before each of the buttons even if they are inside another buttons if statement
Or even better if you have Unity 4.6 you could use the new UI system which would probably be a better alternative to using GUI
in 4.5 unfortunately. And no adding if's didn't do it :c
Best Answer
Answer by vintar · Feb 22, 2015 at 05:09 AM
Use a bool;
bool clicked;
if(GUI.Button(new Rect (Screen.width/2, Screen.height/3, Screen.width/4, Screen.height/3), shopKeepMenu1))
{
clicked = true;
}
if(clicked)
{
if(GUI.Button(new Rect(Screen.width/2,Screen.height/4,Screen.width/4, Screen.height/3),testTexture1)
{
//do something
clicked = false;
}
}
Your answer
Follow this Question
Related Questions
Change GUI.Button Texture on runtime 1 Answer
Null reference exception[SOLVED] 1 Answer
Button Texture Issues?? 1 Answer
GUI Button Not Displaying? 1 Answer
proper inventory system issue.. 1 Answer