- Home /
Question by
billa9432 · Oct 15, 2015 at 04:53 PM ·
camera-look
How to disable Mouse Look On Pause Menu??
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;
}
}
}
Comment
Answer by TeohRIK · Oct 17, 2015 at 10:08 AM
erm...not sure where you attach your script, I assume you attach under the same object You need to use this instead of just MouseLook
GetComponent<UnityStandardAssets.Characters.FirstPerson.MouseLook> ()
Your answer
