Bug with Windows Scaling?

Hi,

I am trying to report an issue through the Unity Hub Bug Reporter, but this doesn’t seem to work (which it did previously) ironically… That’s why I am posting this here.

I am experiencing, what I believe to be, a bug regarding Windows Scaling.

What I am trying to do it project world points onto the scene view (Vector3 to Vector2). Then I use these coordinates to draw GUI onto the scene view (in my case GUI.button). If Windows GUI scaling is set to 100%, all is well. If you set it to anything else, these values to not map anymore. This is mostly a problem on 4K screen, on which the GUI scale is usually >100%.

Here is a clip of the behaviour at 100% scale (right) and 150% scale (left).
7895050--1005373--firefox_6a0ct7FURY.gif

This piece of code can reproduce the problem:

//Get screen position
Vector2 screenLabelPosition = (Vector2)SceneView.currentDrawingSceneView.camera.WorldToScreenPoint(Vector3.zero);

//Draw button
GUI.Button(new Rect(screenLabelPosition.x, Screen.height - screenLabelPosition.y, 100f, 20f), "SomeText", GUI.skin.label);

Do this with Windows scaling at 100%, then at for example 150% and see the difference.

The WorldToScreenPoint does take the GUI scaling into account, the drawing of the Button however does not. As such, these two values do no longer map correctly.

Does anybody else have this issue? Do you know how to get around this?
I could play with settings like DPI to detect the scale, but I suspect this could introduce other bugs elsewhere.
What are your thoughts?

Thanks! :slight_smile:

Bump!