Pause Menu Problems

Hello, I am having a problem with my C# pause script. What happens is when “escape” is pressed to open the menu it’s fine. On the other hand when you press it to close the menu it won’t open anymore. I can see that it turns the script off when you close the menu but it cannot turn it back on for some reason. Can anyone help me? thanks in advanced. Here’s my script:

using UnityEngine;
using System.Collections;

public class PauseGame : MonoBehaviour {
public Transform Canvas;
public Transform Player;

//Update is called once per frame
void Update () {
	if (Input.GetKeyDown("escape"))
public void Pause()
	if (Canvas.gameObject.activeInHierarchy == false)
		Canvas.gameObject.SetActive (true);
		Time.timeScale = 0;
		GameObject Player = GameObject.FindGameObjectWithTag ("Player"); enabled = true;
		Time.timeScale = 1;
		GameObject Player = GameObject.FindGameObjectWithTag ("Player"); enabled = false;


@NEGATIVERAGDOLL when things like this happens, you might want to test “exactly which line is reached in the code” (sorry for poor English). You can do this by putting Debug.Log() whithin code and check Console to see if it gets printed out or not, or by putting breakpoints if you know how to use the debugger, which comes with the built-in MonoDevelop or other script editor.

You can put Debug.Log("!") in Update() to test. I believe you will find that after you press escape, no more “!” gets printed. This is because when a Component is disabled, its Update() is not being called. Also when a GameObject is deactivated, all attached Components’ Update() are not being called. There are several built-in event functions that are only called when being enabled/active. Update() is one of them. I currently can’t find a list though… but you can always test it yourself when needed :slight_smile:

In your script there are several lines (that might be) related to this issue.

Canvas.gameObject.SetActive(false); // This is not related if your script is not attached to the Canvas itself


enabled = false;

You might want to think about how you want to design your Pause Menu.

@Hatsuko Thank you so much. All I had to do was remove the enabled = false; as you said!! :slight_smile: