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

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.

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;

My issue has been placed under another bug (Unity Issue Tracker - [WebGL] Mouse position is not relative to the canvas when using the new input system) 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: (Case 1357476) Input detection is detected relative to browser size instead of canvas size in WebGL

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!

1 Like

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.

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 @KamilCSPS 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.

This issue perfectly describes our problem.

1 Like

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!

3 Likes