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).
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();
}
}
}