I’m trying to make pause menu for my project. I took help from Brackeys’ video for the same. The only issue is when I press escape (as specified in KeyCode) key during the play mode nothing happens.
This is the script that I’m using.
using UnityEngine;
public class PauseMenu : MonoBehaviour
{
public static bool gameIsPaused = false;
public GameObject pauseUI;
void update()
{
if(Input.GetKeyDown(KeyCode.Escape))
{
if(gameIsPaused == true)
{
resume();
}
else if(gameIsPaused == false)
{
pause();
}
}
}
public void resume()
{
pauseUI.SetActive(false);
Time.timeScale = 1f;
gameIsPaused = false;
}
void pause()
{
pauseUI.SetActive(true);
Time.timeScale = 0f;
gameIsPaused = true;
}
public void loadMenu(string name)
{
Debug.Log("Loading " + name);
Time.timeScale = 1f;
Application.LoadLevel(name);
}
public void quit()
{
Application.Quit();
Debug.Log("Quitting Game");
}
}