Search Issue Tracker

Duplicate

Votes

4

Found in

2018.3.0a8

Issue ID

1068201

Regression

No

Input.MousePosition is offset from the cursor

Windows

-

Input.MousePosition seems to be offset from the cursor slightly. Currently this affects:

- The editor (Always)
- The player (When not fullscreen)

The offset is fairly small, only ~30 pixels, but it causes some unintended behaviours. This offset also seems to have got worse over time. I performed a test when I locked the cursor to the center of the screen and then moved a UI image to Input.MousePosition. In this situation the localPosition.y of the UI Image should be 0, but I found the following offsets using different versions of Unity:

2017.3 = ~15 pixels
2018.1 = ~20 pixels
2018.3 = ~30 pixels

Steps to Reproduce:

1. Install Unity
2. Open the attached project
3. Open ScreenPointToRay.scene
4. Enter play mode
5. Move the mouse to the very tip of the upper corner of the ground plane and observe the ball as it follows the mouse

Result:
Ball will be slightly intersecting the top of the mouse pointer by a few pixels

Expected Result:
Ball should appear just above the tip of the mouse pointer

Important note:

The original repro steps (using the SetUIToMousePosition) are not valid. The scenario assumes, when the mouse is "locked", the mouse position is moved to the exact center of the GameView and then calculates the offset using the UI Canvas (which is precisely centered). The problem is, the cursor is only positioned *about* the center of the view and not necessarily at the precise center. Since the purpose of locking the cursor is to get movement deltas, the mouse position should be ignored in this state.

While the test did help to illustrate the bug, it also acted as a red-herring: the offset is still non-zero in Windows Player (because the locked mouse position isn't exactly in center), but the bug doesn't repro in the Player. It was an Editor specific bug.

Tested on 2017.3.0f1, 2018.1.0f1, 2018.2.0f2, 2018.3.0a7, 2018.3.0a8

  1. Resolution Note (2018.3.X):

Comments (6)

  1. furzOnZack

    Feb 12, 2021 08:56

    Same in 2019.4.19f1. Seems to haunt unity since... forever. I guess I go back to Unreal.

  2. shubhamswaraj2021

    Aug 18, 2020 11:36

    good one <a href="https://www.lyricsauto.com">lyricsauto</a>

  3. capkoh

    Oct 30, 2018 10:01

    Have the same issue in 2018.3b6. Offset in Editor in the game window in the Y coordinate is around 6 pixels. So, if I put cursor on the bottom edge of the screen, then the Y coordinate returned in Input.mousePosition is 6. Also have small offset in X, around 3 pixels. I'm running Editor on Windows 10.

  4. DanStreaman

    Oct 17, 2018 16:43

    Can't understand why this is "Not yet prioritized for a release" ?
    This is a critical bug, as it breaks any game using UI components.
    Please note that this bug was _not_ present in 2018.2, therefore this is a regression.

  5. emaber

    Oct 17, 2018 16:05

    Hi, Severity implies there is a workaround available but I don't see any mentioned. Can someone detail the workaround? I know I can just offset it when I explicitly read the mouse position, but I think we need something that would work also on prepackaged components like the UI Button for example.

  6. VincentPaquinUbiant

    Oct 11, 2018 13:06

    I can confirm I have the same problem, small UI buttons are starting to get hard to click on.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.