- Home /
Question by
gamegrime · May 24, 2011 at 12:50 AM ·
not workingcursor
Cursor lock not working
I set tab as my fire3 on input and when I go to the game it doesn't lock the cursor or show any difference when pressing escape.
I also am using a hide cursor script on my char controller could this be effecting it?
The script is using UnityEngine; using System.Collections;
public class CursorLock : MonoBehaviour {
void DidLockCursor() {
Debug.Log("Locking cursor");
if (Input.GetKeyDown("Fire3" ))
guiTexture.enabled = false;
}
void DidUnlockCursor() {
Debug.Log("Unlocking cursor");
guiTexture.enabled = true;
}
void OnMouseDown() {
Screen.lockCursor = true;
}
private bool wasLocked = false;
void Update() {
if (Input.GetKeyDown("escape"))
Screen.lockCursor = false;
if (!Screen.lockCursor && wasLocked) {
wasLocked = false;
DidUnlockCursor();
} else
if (Screen.lockCursor && !wasLocked) {
wasLocked = true;
DidLockCursor();
}
}
}
Comment