- Home /
On GUI Going Away
So i have been trying to make an in game pause menu, it all works fine but when i click the store button all the pause gui stays there and the store gui gets created ON TOP of the pause menu gui. How can i get rid of the pause menu gui when i click the store button. My script is:
var paused : boolean = false; var store = false;
function Update () { if(Input.GetButtonDown("Pause")) { if(!paused) { Time.timeScale = 0; paused=true; GameObject.Find ("Main Camera").GetComponent("MouseLook").enabled = false; GameObject.Find ("Player").GetComponent("MouseLook").enabled = false; OnGUI (); } if(Input.GetButtonDown("Pause")) { if (paused) { Time.timeScale = 1; paused=false; GameObject.Find ("Main Camera").GetComponent("MouseLook").enabled = true; GameObject.Find ("Player").GetComponent("MouseLook").enabled = true; } } } }
function OnGUI () { if (paused) { GUI.Box (Rect (320,216.5,Screen.width/2,Screen.height/2), "PAUSED"); if (GUI.Button(Rect(590,400,100,50),"OPTIONS")) { } if (GUI.Button(Rect(590,300,100,50),"STORE")) { store = true; } if (GUI.Button(Rect(590,550,100,50),"QUIT")) { } if (store) { GUI.Box (Rect (320,216.5,Screen.width/2,Screen.height/2), "STORE"); if (GUI.Button(Rect(590,400,100,50),"")) { } if (GUI.Button(Rect(590,300,100,50),"")) { } if (GUI.Button(Rect(590,550,100,50),"")) { } } } }
Can someone please help me! Thanks.
I asked for something similar sometime ago, take a look: http://answers.unity3d.com/questions/224044/disable-gui.html
Your answer
Follow this Question
Related Questions
GUI.Style is messing up big time 0 Answers
Converting world coordinates to screen coordinates 1 Answer
GUI.Button with double functionality 2 Answers
GUI: Overlapping and Box size collision 1 Answer
gui rotational issues 0 Answers