hi any idea why this isnt working? all like 50 examples ive looked at use this method and all it says for me is
Assets/EnableandDisableMouse.cs(27,51): error CS1061: Type UnityEngine.Component' does not contain a definition for
enabled’ and no extension method enabled' of type
UnityEngine.Component’ could be found (are you missing a using directive or an assembly reference?)
using UnityEngine;
using System.Collections;
public class EnableandDisableMouse : MonoBehaviour {
public bool onoroff = true;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update ()
{
if(Input.GetKeyDown(KeyCode.Tab))
{
onoroff = !onoroff;
}
if (onoroff == true)
{
Screen.showCursor = false;
}
if (onoroff == false)
{
Screen.showCursor = true;
GetComponent("MouseLook").enabled = false;
}
}
}
Updated the script but now the mouse look on the camera wont shut off any ideas?
using UnityEngine;
using System.Collections;
public class EnableandDisableMouse : MonoBehaviour {
public bool onoroff = true;
MouseLook playerLook;
MouseLook playerCameraLook;
// Use this for initialization
void Start ()
{
playerLook = (MouseLook)GameObject.Find ("PlayerController").GetComponent ("MouseLook");
playerCameraLook = (MouseLook)GameObject.Find ("Main Camera").GetComponent ("MouseLook");
}
// Update is called once per frame
void Update ()
{
if(Input.GetKeyDown(KeyCode.Tab))
{
onoroff = !onoroff;
playerLook.enabled = !playerLook.enabled;
playerCameraLook.enabled = !playerCameraLook.enabled;
}
if (onoroff == true)
{
Screen.showCursor = false;
}
if (onoroff == false)
{
Screen.showCursor = true;
}
}
}