c# – Unity In-game pause menu not working?


I have followed a tutorial to implement a pause screen for my platformer game. I followed it thoroughly but could not get it working. When I press the escape button which I assigned under the project manager under the name “Pause”, it just doesn’t do anything. I checked with the Scene view as well, nothing appears. Any help would be appreciated.

 public GameObject PauseUI;

 private bool paused = false;

void Start()
{
    PauseUI.SetActive(false);
}

void Update()
{
   if(Input.GetButtonDown("Pause"))
   {
       paused = !paused;
   }

   if(paused)
   {
       PauseUI.SetActive(true);
       Time.timeScale = 0;
   }

   if(!paused)
   {
       PauseUI.SetActive(false);
       Time.timeScale = 1;
   }
}

enter image description here

enter image description here

enter image description here