I have this script that I know use to work but now it’s not working with Unity 5 and I think I know the problem just don’t know how to fix it exactly. The script is disabling the FPS MouseLook when MouseButtonDown which pops up a GUI menu.
I now get a CS0246 error “The type namespace name ‘MouseLook’ could not be found.”
I think it has something to do with the old FPSController had a MouseLook script applied, but the one I’m using in Unity 5 has the MouseLook script as part of the FPS script.
Is there a way to modify the “GetComponent” to make this work?
using UnityEngine;
using System.Collections;
public class pauseMenu : MonoBehaviour {
bool paused = false;
void Start ()
{
GameObject.Find ("First Person Controller").GetComponent<MouseLook> ().enabled = true;
Screen.lockCursor = true;
Time.timeScale = 1;
}
void Update ()
{
if (Input.GetMouseButtonDown (2))
paused = togglePause ();
}
bool togglePause()
{
if (Time.timeScale == 0)
{
GameObject.Find ("First Person Controller").GetComponent<MouseLook> ().enabled = true;
Screen.lockCursor = true;
Time.timeScale = 1;
return(false);
} else {
GameObject.Find ("First Person Controller").GetComponent<MouseLook> ().enabled = false;
Screen.lockCursor = false;
Time.timeScale = 0;
return(true);
}
}
}
I actually figured out a way around this by modifying the MouseLook.cs script (in Standard Assets, FirstPersonCharacter, Scripts folder) with “IF Statements” to “0” out the X&Y Sensitivity float value ButtonDown. Here’s the modified script.