Hi Guys… My Game has a pause menu “Press Escape In Game It Pauses” But if you move the mouse around to select options/quit/resume etc the actual scene in BG moves since mouse look is enabled… Is there a way to find the Firstperson controller prefab and disable the mouse look script and then on resume re enable it?
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class PauseMenuScript : MonoBehaviour {
public GameObject pausePanel;
public bool isPaused;
private MouseLook mouseLook;
void Start () {
isPaused = false;
}
void Update () {
if (isPaused) {
PauseGame(true);
}
else {
PauseGame(false);
}
if (Input.GetButtonDown ("Cancel")) {
SwitchPause();
}
}
void PauseGame(bool state){
if (state) {
Time.timeScale = 0.0f;
GetComponent<MouseLook>().enabled = false;
}
else {
Time.timeScale = 1.0f;
GetComponent<MouseLook>().enabled = true;
}
pausePanel.SetActive (state);
}
public void SwitchPause(){
if (isPaused) {
isPaused = false;
}
else {
isPaused = true;
}
}
}