Search Issue Tracker

By Design

Votes

0

Found in

2019.4

2020.3

2020.3.33f1

2021.3

2022.1

2022.2

Issue ID

1419206

Regression

No

Pixel Heights isn't correct in Scene view when UI Scaling is set to 125%

Scene/Game View

-

Reproduction steps:
1. Open project "case_1419206.zip"
2. Open Preferences window from Edit > Preferences then change the UI Scaling to 125%
3. Enter Scene view and select ScreenToViewportPoint game object
4. Observe Gizmo's location

Expected result: Gizmo is located near the center of the game object
Actual result: Gizmo's transformation isn't near the center of the game object

Reproducible with: 2019.4.38f1, 2020.3.34f1, 2021.3.2f1, 2022.1.0f1, 2022.2.0a12

  1. Resolution Note:

    The script provided as a sample is using the following code snippet to get the mouse position:
    Vector2 mpos = Event.current.mousePosition;
    mpos.y = SceneView.currentDrawingSceneView.camera.pixelHeight - mpos.y;

    This is incorrect as the 'Event.current.mousePosition' is getting the mousePosition in GUI space and 'SceneView.currentDrawingSceneView.camera.pixelHeight' is in Screen space.

    In order to get the right value the user should be using the following code:
    Vector2 mpos = HandleUtility.GUIPointToScreenPixelCoordinate(Event.current.mousePosition);
    Which will convert the mousePosition from the GUI Space to the Screen one.

    However, looking at the 'Event.current.mousePosition' documentation, the documentation seems wrong as it seems to indicate to the user that the mousePosition is set in ScreenSpace and not in GUISpace.
    Maybe this documentation should be updated regarding this and precise that the result of calling 'Event.current.mousePosition' will be in GUISpace and replace this section of the current doc:

    "Used in EventType.MouseMove and EventType.MouseDrag events. The top-left of the window returns (0, 0). The bottom-right returns (Screen.width, Screen.height).

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.