- Home /
Question by
GoGamingJoe · May 31, 2014 at 06:49 PM ·
gui.buttongui.box
Why Is GUI.Button Not Drawing GUI.Box
void OnGUI(){
GUI.Box (new Rect (Screen.width / 2 - 150, 10 , 300 , 50), "Time You Have Been Going : " + timer.ToString("F1") + " Score : " + Score);
if (GUI.Button (new Rect (Screen.width - 100, 10, 90, 30), "Pause") || Input.GetKey(KeyCode.Escape)) {
Debug.Log("Pause");
GUI.Box(new Rect(Screen.width / 2 - Screen.width / 4, 10, Screen.width / 2, Screen.height - 10), "Pause");
Debug.Log("Pause 2");
Time.timeScale = 0;
}
I'm Trying to make a pause menu but I don't get why it not drawing GUI.Box
Any Help Thanks
Comment
Answer by Jeff-Kesselman · May 31, 2014 at 06:51 PM
This will only draw the box on the one frame the button is clicked on.
You need to set a boolean so you can remember that the button was clicked and then draw the box based on the boolean every frame.
GUI calls are immediate mode, they get cleared after each frame and have to be recalled if you want them in the next one.