Button won't show up in pause.

The game pauses but there is no button. Can somebody please help?

var paused : boolean = false;


function Update () {



    if(Input.GetKeyDown(KeyCode.Escape)  paused == false)
   {
   
   paused = true;
   	if (GUI.Button(new Rect(10, 10, 200, 50), "Disconnect"))
   	{
   		Application.LoadLevel("MainMenu");
   		Network.Disconnect();
   	}
   
   Time.timeScale = 0;
   
   
   
   }
   else if(Input.GetKeyDown(KeyCode.Escape)  paused == true) {
   
   
   paused = false;
   
   
   Time.timeScale = 1;
   
   }
    
    

}

You can’t put OnGUI code in Update; it has to be in OnGUI. Also, that code wouldn’t work like that anyway, since GetKeyDown is only true for one frame, so the button wouldn’t ever show up (except for one frame).

–Eric

This is my first time messing with JavaScript. I usually use C#. Thanks.

What I wrote applies equally to C# as it does to JS.

–Eric

Okay, I rewrote my pause script in C# instead of JavaScript and I changed it to how I thought Eric was talking about. It still doesn’t work though. Can somebody tell me what I need to do to make it work? Thanks.

using UnityEngine;
using System.Collections;

public class TestPause : MonoBehaviour 
{

    public bool IsPaused = false;

	void Update() 
    {
        if (Input.GetKeyDown(KeyCode.Escape)  IsPaused == false)
        {

            IsPaused = true;

            Time.timeScale = 0;

        }
        else if (Input.GetKeyDown(KeyCode.Escape)  IsPaused == true)
        {

            IsPaused = false;

            Time.timeScale = 1;

        }
	}

    public void Pause_Buttons()
    {
        if (IsPaused == true)
            if (GUI.Button(new Rect(10, 10, 100, 50), "Disconnect"))
            {
                Application.LoadLevel("MainMenu");
                Network.Disconnect();
            }
    }
}

Nevermind, I fixed it.

lol funny stuff