Problems with pause menu displaying items and stopping player movement

I have a script that acts as a pause menu and is supposed to completely pause the game, but I’m currently having a problem with it. It stops animations and such, but does not stop the player from looking. Also, the options menu will not show when it is clicked and the resume button does not work. I’m not sure, but the quit button could also be non functional as well, I just haven’t built my game to test it.

Can someone help out? Here is the code: using UnityEngine;using System.Collections;public class PauseMenu2 : MonoB - Pastebin.com

EDIT: The resume and quit buttons now work. I don’t know what I did, but it works now. The only problem I’m having now is being able to move the mouse to look while paused.

Shouldn’t you have some sort of bool change if the player hits escape? Something like:

 if (Input.GetKeyDown(KeyCode.Escape))
        {
paused = !paused;

}

You can disable the MouseLook ability by setting the .enabled flag to false, and then again to true on unPause. I was able to test and get it to work with this:

I added the following to the if(!paused) and set them true again in the else if(paused).

PlayerMouseControllerX.enabled = false;
PlayerMouseControllerY.enabled = false;
using UnityEngine;
using System.Collections;

public class PauseMenu2 : MonoBehaviour
{
	public bool Paused = false;
	public bool ShowPauseMenu = false;
	public bool ShowOptionsMenu = false;
	public static float SensitivityX = 1f;
	public static float SensitivityY = 1f;
	public MouseLook PlayerMouseControllerX;
	public MouseLook PlayerMouseControllerY;
	
	// Use this for initialization
	void Start()
	{
		Paused = false;
		Time.timeScale = 1;
		Screen.lockCursor = true;
		Screen.showCursor = false;
		ShowPauseMenu = false;
		PlayerMouseControllerX.sensitivityX = SensitivityX;
		PlayerMouseControllerY.sensitivityY = SensitivityY;
	}
	
	// Update is called once per frame
	void Update()
	{
		if (Input.GetKeyDown(KeyCode.Escape))
		{
			if (!Paused)
			{
				Paused = true;
				Time.timeScale = 0;
				Screen.lockCursor = false;
				Screen.showCursor = true;
				ShowPauseMenu = true;
				PlayerMouseControllerX.sensitivityX = 0;
				PlayerMouseControllerY.sensitivityY = 0;
				PlayerMouseControllerX.enabled = false;
				PlayerMouseControllerY.enabled = false;
			}
			else if (Paused)
			{
				Paused = false;
				Time.timeScale = 1;
				Screen.lockCursor = true;
				Screen.showCursor = false;
				ShowPauseMenu = false;
				PlayerMouseControllerX.sensitivityX = SensitivityX;
				PlayerMouseControllerY.sensitivityY = SensitivityY;
				PlayerMouseControllerX.enabled = true;
				PlayerMouseControllerY.enabled = true;
			}
		}
	}
	void OnGUI()
	{
		
		{
			if (ShowPauseMenu)
			{
				// Make a background box
				GUI.Box(new Rect(10, 10, 650, 300), "Paused");
				
				// Make the resume button
				if (GUI.Button(new Rect(290, 100, 80, 20), "Resume"))
				{
					ShowPauseMenu = false;
					Time.timeScale = 1;
					Screen.showCursor = false;
					Screen.lockCursor = true;
				}
				// Make the second button that will kill the process
				if (GUI.Button(new Rect(290, 200, 80, 20), "Quit"))
				{
					Application.Quit();
				}
				if (GUI.Button(new Rect(290, 150, 80, 20), "Options"))
				{
					ShowPauseMenu = false;
					ShowOptionsMenu = true;
				}
			}
			else if (ShowOptionsMenu)
			{
				GUI.Box(new Rect(10, 10, 650, 300), "Options");
				GUI.Label(new Rect(150, 200, 150, 20), "Sensitivty X: (" + SensitivityX.ToString() + ")");
				GUI.Label(new Rect(150, 225, 150, 20), "Sensitivty Y: (" + SensitivityY.ToString() + ")");
				SensitivityX = GUI.HorizontalSlider(new Rect(200, 200, 150, 20), SensitivityX, 0.1f, 20f);
				SensitivityY = GUI.HorizontalSlider(new Rect(200, 225, 150, 20), SensitivityY, 0.1f, 20f);
				//If the "Return" button is pressed, go back to the main menu
				if (GUI.Button(new Rect(209, 100, 80, 20), "Return"))
				{
					ShowPauseMenu = true;
					ShowOptionsMenu = false;
				}
			}
		}
	}
}