Search Issue Tracker
Input.MousePosition is offset from the cursor
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
Ball will be slightly intersecting the top of the mouse pointer by a few pixels
Ball should appear just above the tip of the mouse pointer
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
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
- Advanced Object Picker switches to Classic with Error "Exception caught with search engine (Object Selector)Advanced" when opening multiple Object Picker windows
- UI Image Maskable property not recognized by EventSystem when using RectMask2D
- The "secondary" touchpoint reverts to the previous position when the "primary" touchpoint is released and re-engaged on WebGL applications
- GameObject with Visual Effect Graph Component is blooming when the VFX Graph Color is set to "0" and Alpha is set "1"
- Audio Reverb Zone Component is not applied when Effects are reordered in the Mixer