- Home /
Question by
yankees26an · Dec 21, 2011 at 10:10 PM ·
javascriptmenupause
show pause menu issues
if (Input.GetButtonUp("Fire1")) {
AudioListener.pause = true;
if(!paused) {
//GUI.Box(new Rect(0,0,Screen.width,Screen.height),"");
Time.timeScale = 0;
paused = true;
}
else {
Time.timeScale = 1;
paused = false;
AudioListener.pause = false;
}
}
I cannot instantiate a new GUI.Box inside Update(). But if I put that code in OnGUI, it doesn't work(not run every frame). How can I make a menu show up? I was thinking of Event listeners, but is there something more intuitive?
Comment
Answer by FLASHDENMARK · Dec 21, 2011 at 10:16 PM
Why not have both functions?
function Update (){
//Check for input and set paused to true and what not.
}
function OnGUI{
//Check if paused is true
if(paused){
//Draw GUI
}
}
Use Update to check for input and OnGUI to draw GUIs.
Your answer
Follow this Question
Related Questions
Script that makes the mouse cursor invisible. 3 Answers
Making a Pause Menu 1 Answer
How do I make a pause menu? 3 Answers
Stat bars in Menu system? 1 Answer
Pause Menu 3 Answers