Search Issue Tracker

Fixed in 5.3.0

Votes

6

Found in

4.6.0f3

Issue ID

653780

Regression

No

[LockCursor] Screen.lockCursor loses its lock on mouse click in the editor

Input

-

To reproduce this issue:

1. Open the attached project
2. Open 'TestScene'
3. Note the LockCursor script attached to Main Camera
4. Play the scene. Note that the mouse cursor disappears and the console messages indicate the cursor is locked, as expected
5. Click any mouse button. The cursor auto-unlocks

If you put Screen.lockCursor=true in Update() using something like: " if (Input.GetKey(KeyCode.A)) Screen.lockCursor = true; " . Then, after clicking A, the lock works as expected and is only unlocked after pressing escape.

Only on Windows

The documentation suggests that : "In the Editor the cursor will automatically be unlocked when you press escape"

Comments (6)

  1. alan-lawrance

    Oct 27, 2015 20:06

    Not entirely sure if this is the same issue -- but when we unlock the cursor in editor the cursor is centered on the Scene view (when it should be in the Game view). Workaround is to not show Game and Scene view at the same time, but that is not ideal.

  2. tmdchi

    Oct 21, 2015 11:05

    Nope, false alarm. Still happens... Sorry.

  3. tmdchi

    Oct 21, 2015 10:59

    Just found out that it only happens if the Game window is sharing the Scene window space (not docked side to side, that is). When aboth windows are visible, the locked state works fine.

  4. tmdchi

    Oct 20, 2015 14:02

    Still happens since several versions ago. I think what happens is that the cursor is locked inside a different window than the game one. i. e. instead of being centered and locked in the Game window, it's centered and locked in the Console window, so if user clicks, focus is given to the Console window.

  5. UltronTM

    Dec 22, 2014 19:11

    I just downloaded Unity 4.6.1f1 and this problem changed a bit.

    My game locks the cursor at startup. And when I hit TAB to open the inventory, the unlocked cursor always appeared in the center of the game tab. Now it does appear exactly on that spot where it would appear when just clicking. This only happens once though. Meaning If I hit TAB to lock and hit TAB again to unlock, the cursor appears in the center of the game tab.

    Obviously this cursor is being haunted. Maybe Steve Jobs? I know this bug is Window only. :D

  6. UltronTM

    Dec 21, 2014 21:07

    Same problem here on Windows 8.1.

    Also, no matter how much I move the mouse back and forth. When clicking, the cursor appears outside the game tap and ALWAYS at the same spot. In my case it's not the over console because I have a different layout.

    When enabling Maximize on Play, it unlocks, too. But only the first time. Unity needs closing and restarting to cause this auto unlock when Maximize on Play is enabled.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.