I used to be able to highlight & click world canvas GUI elements, like buttons, using a locked, hidden & centered cursor. This simulated using the camera’s view as a pointer. It doesn’t seem to be working anymore in 5.4.0f2. GameObjects still respond as expected using MouseOver & MouseDown. When the cursor is visible, the GUI buttons work fine (but I want it locked & hidden).
Hey So this is by design now. There are no guarantees of where a locked cursor should be on the screen. Thus we have removed the interactability of a locked cursor with the UI. To simulate this behavor you would need to derive from StandaloneInputModule and override the GetMousePointerEventData function to force the position to anything you want. A good example is the VR module VR Best Practice - Unity Learn
That example has no mention of GetMousePointerEventData or the word “cursor”. I’m struggling to find a straightforward solution for this, which seems like there no longer is one. The alternative you are suggesting sounds far more complex than what was possible before. The frustrating thing is, LockedCursor still operates just the way I want with MouseOver & MouseDown – at the center of the screen. The only thing that stopped working was GUI interactions, which were reliable. A better solution would be to just provide an option of where the locked cursor will be set – center / top left / specific coordinates etc, so a guarantee could be provided.
Well this sucks… i used that functionality heavily. I went to make a bug report about it and what my surprise was, when i found out that this wasn’t a bug, but just a bad design decision. Why not add a CursorLockMode.LockedWithoutEvents; instead so you won’t break every project that relies on that functionality and decided to upgrade to the new unity version?
Now i have to use some ugly hacks to get it working again
Edit:
I tried doing this in Start:
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = true;
But the cursor remains invisible.
After placing Cursor.visible = true; into Update, the cursor is visible, but the mouse events for the UI are still not triggered, they only are after i press the escape which unlocks the cursor completely.