Quantcast
Channel: Questions in topic: "hide gui"
Viewing all articles
Browse latest Browse all 6

How to hide/show GUI Buttons through another GUI Button?

$
0
0
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?

Viewing all articles
Browse latest Browse all 6

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>