Hi all,
I'm a new Unity user and C# scripter and I want to be able to click a button to trigger the showing of several more buttons (this is for an options menu: sound/music toggle). I couldn't figure out how to show/hide Buttons OnGUI so I tried this: (didn't work)
public bool opt = false;
void OnGUI() {
if(GUI.Button(new Rect(Screen.width / 5, Screen.height * 13 / 30, Screen.width / 13, Screen.height / 30), "Opt") {
opt = !opt;
}
if(opt) {
if(GUI.Button(new Rect(Screen.width / 5, Screen.height * 13 / 30, Screen.width / 13, Screen.height / 30), "Music Off") {
//do
}
}
}
I have a feeling that GUI.Buttons can't be put inside if statements but can't figure out what to do... Any suggestions for this problem?
↧