Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Bug New Input System preview break mouse position calculations in fullscreen non-native resolutions

Discussion in '2021.2 Beta' started by kamil-dawidow, Aug 26, 2021.

  1. kamil-dawidow

    kamil-dawidow

    Joined:
    May 29, 2018
    Posts:
    6
    This bug is reproducible in Unity 2021.2.0b7 and 2021.2.0b8 using InputSystem 1.1.0-pre.5 or 1.1.0-pre.6 (older versions may have the same problem). I've observed UI problems using UIToolkit but since Mouse.current.position.ReadValue() doesn't work correctly then I guess UIs based on the old UI framework may be affected by this bug too.

    To observe this bug you have to:

    1. Open a project with some buttons or somehow printing on the screen:
    UnityEngine.InputSystem.Mouse.current.position.ReadValue();

    2. Set the resolution to a non-native resolution for your screen (e.g. 1600x1200 for me since I have a 2560x1440 screen) and turn on fullscreen, so:
    Screen.SetResolution(1600, 1200, true);

    3. "Build and run" the project.
    4. Just try to click a button or check the printed mouse position. The button's rendered area doesn't match its clickable area and the printed mouse position's y isn't valid. The mouse position being broken is especially visible when placing the cursor at the top or at the bottom of the screen. In my case on a 2560x1440 screen after I set the resolution to 1920x1200 and place the cursor at the bottom of the screen the mouse position's y is equal to 240, not to 0.
     
  2. KamilCSPS

    KamilCSPS

    Joined:
    May 21, 2020
    Posts:
    448
    Very similar issue with WebGL and new input system, has been the case since early July.

    All clickable areas using the new input system + UI Toolkit are offset relative to the top-left corner of the browser window instead of the canvas. So moving the canvas breaks the UI completely (e.g. can't center it in CSS or use non-uniform scaling).

    What you're describing appears to be this issue, present since B1;
    https://issuetracker.unity3d.com/is...ler-than-native-with-new-input-system-enabled

    My issue has been placed under another bug (https://issuetracker.unity3d.com/is...-with-runtimeinitializeonloadmethod-attribute) so there's no way to really track the progress of -that particular- part of the bug or if both are related. Latest Input System version will not fix it, QA confirmed it has to be fixed in-editor code.

    I tried re-reporting it here: https://forum.unity.com/threads/cas...size-instead-of-canvas-size-in-webgl.1155038/

    Been told by @LeonhardP that we can 'expect' a fix to land in B10. Fingers crossed as this has been a blocker for any WebGL projects that want to use 2021.2, and 2021.2 is -the- WebGL upgrade version we've been waiting for years!
     
    Last edited: Aug 26, 2021
    kamil-dawidow likes this.
  3. kamil-dawidow

    kamil-dawidow

    Joined:
    May 29, 2018
    Posts:
    6
    Thanks for the link to the issue and the additional info! We might be able to use the "Exclusive Fullscreen" workaround. But let's hope that the original issue will get fixed as soon as possible, alt-tabbing in the exclusive fullscreen mode is much slower than in the default mode.
     
  4. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,136
    When I wrote that, b10 was the best case scenario for when the fix might become available in 2021.2. Unfortunately it is going to slip further though and won't be fixed in b10.

    The known issue mentioned by @KamilDA is specific to WebGL. If you are experiencing this on another platform, please submit a bug report for it as this might be a different issue.
     
    Last edited: Aug 27, 2021
  5. kamil-dawidow

    kamil-dawidow

    Joined:
    May 29, 2018
    Posts:
    6
    LeonhardP likes this.
  6. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    I'm trying to get this in sooner than later. I agree that using exclusive fullscreen is not a good workaround. Another workaround is rendering at native resolution for now.

    Sorry for inconvenience!