I am having problems with a simple Pause Menu script I made. The Idea is that when I press the P key, the game pauses and shows a menu. There should also be a button in the corner of the screen to pause the game. Currently the game pauses (Physics timescale goes to Zero) but none of the buttons appear. The script is a component of the Main Camera on a first person Character controller GameObject. Could Somebody please tell me what I am doing wrong, and give some suggestions?
The code is below:
import UnityEngine
class PauseMenuHandler (MonoBehaviour):
private isPaused as bool = false
def FixedUpdate ():
if Input.GetKeyDown(KeyCode.P):
IsPaused = true
Time.timeScale = 0
def OnGUI():
if isPaused:
if GUI.Button(Rect(Screen.width/2-100, 50, 200, 50), "Resume game"):
isPaused = false
Time.timeScale = 1
if GUI.Button(Rect(Screen.width/2-100, 150, 200, 50), "Quit"):
Application.Quit()
if Application.isEditor or Application.isWebPlayer:
Debug.Log("Failed to quit due to being run in editor/webplayer!")
if GUI.Button(Rect(10,10,50,20), "||"):
isPaused = true
Time.timeScale = 0