- Home /
Question by
NarallandaKaratoga · Jul 01, 2018 at 03:28 PM ·
cursorlock-cursorlockcursor
Cursor.lockState does not work
simply coded:
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
And there is nomore code changing the Cursor.lockState.
It works fine except when I'm using window mode, switching out with Alt+Tab. Then the mouse will not be locked at all, even after switching back and clicking inside the window many times.
I've tried development build, normal build and in-editor run, all of them have the same issue.
Unity version is 2018.1.6f1.
Comment
Answer by Nostr0 · Jul 01, 2018 at 06:53 PM
It's not a perfect solution but if I understand your problem this might help. When Alt+Tabing in the window and clicking with the mouse it should lock itself again.
(Input.GetMouseButtonDown (0))
{
Cursor.lockState = CursorLockedMode.Locked;
}
I am new to Unity too but I hope I could help
doesn't work. Also tried
void Update()
{
Cursor.lockState = CursorLock$$anonymous$$ode.Locked;
}
and
void Update()
{
Cursor.lockState = CursorLock$$anonymous$$ode.None;
Cursor.lockState = CursorLock$$anonymous$$ode.Locked;
}
This value won't change whatever I do, until there's a script modifying it.