Search Unity

UWP bug with hiding cursor (Cursor.lockState)?

Discussion in 'Windows' started by MarcusTheMainMan, Oct 10, 2019.

  1. MarcusTheMainMan

    MarcusTheMainMan

    Joined:
    Nov 29, 2012
    Posts:
    218
    I have recently found that the following code works as expected on android and win32 builds but not as expected in a UWP build. It seems the code is not working the same in a UWP build.

    - Using win32 or android builds, the cursor will stay onscreen and be seen.
    - However, when testing with a UWP build, the cursor disappears. You can still double click and stuff, but can not see the mouse cursor. It looks like the UWP is incorrectly hiding the cursor.

    I am not 100% but wanted someone else to see. It could just be me. I have spent the last 3 days isolating this issue. It could be a variable issue not correctly being set (script execution order), but doubt it. If someone could check out the functionability of these commands for UWP builds.

    Cursor.lockState = CursorLockMode.Confined;
    Cursor.lockState = CursorLockMode.None;


    void OnEnable ()
    {
    if (ToggleMouseTouch.areWeUsingTheMouseInput_INT == 0)
    {
    Cursor.lockState = CursorLockMode.Confined;
    }
    else
    {
    Cursor.lockState = CursorLockMode.None;
    }
     
  2. timke

    timke

    Unity Technologies

    Joined:
    Nov 30, 2017
    Posts:
    78
  3. MarcusTheMainMan

    MarcusTheMainMan

    Joined:
    Nov 29, 2012
    Posts:
    218
    OK, I'll take your word for it cause there are about 2.7 billion pages of documentation and it changes on every new unity build. So now the obvious guys says..."Can't you give a warning or something when building to UWP????". I fyou know it's not supported, then can't you just tell us? It kind of sucks spending a week hunting this down and I know a year or 2 from now I'll probably have this same problem again.

    I just looked at that page and you know what, I copied that exact code to my script. So yeah, when looking for stuff we don't read every last bit of info. There's just too much of it. Hint: how about in the comments in that page you put something like this in the actual script so when ones copies and pastes he will see it.:
    //DOES NOT WORK IN UWP BUILDS.

    It is off the right side of the screen. Way too long of a comment so can not see on monitor. So make it 2 lines.
    //This script makes Buttons that control the Cursor's lock state. Note that the Confined mode only works on Windows and Linux Standalone platform build


    Like
    //This script makes Buttons that control the Cursor's lock state.
    //Confined mode only works on Windows 32/64 & Linux Standalone platform builds.
    //Does not work in UWP builds.
     
    Last edited: Oct 12, 2019 at 1:57 AM