Search Unity

World GUI & Locked Cursor Doesn't Work Anymore

Discussion in '5.4 Beta' started by phr00t, Jul 26, 2016.

  1. phr00t

    phr00t

    Joined:
    Apr 19, 2016
    Posts:
    41
    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).

    I'm submitting a bug report now. Any ideas?
     
  2. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,138
    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 https://unity3d.com/learn/tutorials/topics/virtual-reality/interaction-vr
     
    Last edited: Jul 26, 2016
  3. phr00t

    phr00t

    Joined:
    Apr 19, 2016
    Posts:
    41
    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.
     
    elhongo likes this.
  4. phr00t

    phr00t

    Joined:
    Apr 19, 2016
    Posts:
    41
    duch and zyzyx like this.
  5. Compressed

    Compressed

    Joined:
    Sep 20, 2014
    Posts:
    59
    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.
     
    Last edited: Jul 27, 2016
    lodendsg, elhongo and hellcaller like this.