- Home /
Question by
sengel · Apr 11, 2014 at 08:31 PM ·
cursorlock-cursor
Can I lock a cursor without hiding it?
I have
Screen.lockCursor = true;
Screen.showCursor = true;
in my start function, but the cursor shows up locked (good!) AND hidden (bad!) when I start the game. Any ideas why this is happening or how to avoid it?
EDIT Here's the whole code:
using UnityEngine;
using System.Collections;
public class CameraSwitcher : MonoBehaviour {
public Camera masterCam;
public Camera slaveCam;
public GameObject slave;
private CharacterMotor masterMot;
private CharacterMotor slaveMot;
// Use this for initialization
void Start () {
masterMot = GetComponent<CharacterMotor> ();
slaveMot = slave.GetComponent<CharacterMotor> ();
masterMot.canControl = true;
slaveMot.canControl = false;
masterCam.enabled = true;
slaveCam.enabled = false;
Screen.lockCursor = true;
Screen.showCursor = true;
}
// Update is called once per frame
void Update () {
if(Input.GetButtonDown("CamSwitch")) SwitchCam();
}
void SwitchCam() {
masterCam.enabled = !masterCam.enabled;
slaveCam.enabled = !slaveCam.enabled;
masterMot.canControl = !(masterMot.canControl);
slaveMot.canControl = !(slaveMot.canControl);
Screen.lockCursor = !Screen.lockCursor;
Screen.showCursor = true;
}
}
Comment
Is there anything else that changes anything with the mouse being shown or not?
Can you post the whole script?
Your answer
![](https://koobas.hobune.stream/wayback/20220613142517im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Unable Escape Key to Unlock cursor 2 Answers
Cursor Problem / Toggle Lock and Unlock 0 Answers
Hiding a Cursor? 3 Answers
Screen.CursorLock problems 2 Answers
Is it possible to lock a cursor without hiding it?? 0 Answers