I’m trying to make a basic escape menu but when I press escape nothing happens. Here’s my code:
public GameObject EscMenu; // ESCAPE MENU GAMEOBJECT
void Start() {
EscMenu.SetActive (false);
}
void Update () {
if ((Input.GetKeyDown(KeyCode.Escape) == true) && (EscMenu.activeInHierarchy == false)) { // IF ESCAPE IS PRESSED AND ESCAPE MENU IS NOT ACTIVE
EscMenu.SetActive(true); // ACTIVATE ESCAPE MENU
Time.timeScale = 0; // SET TIMESCALE TO ZERO (FREEZE)
} // END IF
if ((Input.GetKeyDown (KeyCode.Escape) == true) && (EscMenu.activeInHierarchy == true)) { // IF ESCAPE IS PRESSED AND ESCAPE MENU IS ACTIVE
EscMenu.SetActive(false); // DEACTIVATE ESCAPE MENU
Time.timeScale = 1; // SET TIMESCALE TO ONE (DEFAULT)
} // END IF
}
The canvas of the pause menu is assigned to EscMenu, and the script is attached to FPSController included with Unity. Does anyone have any ideas as to why this is happening?