Search Issue Tracker
By Design
Votes
0
Found in
2018.2.0a6
2018.4
2019.3
2019.3.1f1
2020.1
2020.2
Issue ID
1220751
Regression
Yes
WorldToScreenPoint transforms offsetted screen position when display is scaled above 100% on Windows 10
How to reproduce:
1. Open the attached '1220751.zip' project
2. Open 'SampleScene' Scene
3. Select 'GameObject' GameObject in the Hierarchy and observe its position in the Scene View
4. Open Display Settings and change Scale and layout section's scaling to 150% on Windows
5. Back to the Editor and select 'GameObject' GameObject in the Hierarchy
Expected result: GameObject's position is drawn at the object origin
Actual result: GameObject's position is offsetted
Reproducible with: 2018.2.0a6, 2018.4.18f1, 2019.3.4f1, 2020.1.a25, 2020.2.0a1
Not reproducible: 2018.2.0a5
Could not test with: 2017.4.37f1 because Presets namespace is not introduced
Notes: Video and project of reproduction attached in Edit
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- [Quest] Materials are not rendering in Player when "Single Pass Instanced \ Multi-View" is selected and "Surface Type" is set to "Transparent"
- Hair master stack shader on hair is blown out when there is a backlit light on it
- [Editor] Profiler (Standalone Process) "Live" button is greyed out by default
- UIToolkit bindings on RadioButtonGroup is not displaying the selected radio button when the choice list is bound
- Multiple Video Players are not playing simultaneously when played in WebGL
Resolution Note (2020.1.X):
The code is working as expected.
According to https://docs.unity3d.com/ScriptReference/Camera.WorldToScreenPoint.html WorldToScreenPoint defines ScreenSpace in pixels.
Most modern displays are resolution independent. Their logical area is not the same as their pixel resolution. In order to get the correct resolution for placement on the screen, you have to transform the coordinates from pixels to screen coordinates by dividing by EditorGUIUtility.pixelsPerPoint (https://docs.unity3d.com/ScriptReference/EditorGUIUtility-pixelsPerPoint.html)
In addition, the Y axis is inverted for GUI space, with (0,0) being the top left corner instead of the bottom left corner (See https://docs.unity3d.com/ScriptReference/Rect.html for an example). You will have to convert camera hight from pixels to points using EditorGUIUtility.pixelsPerPoint and then subtract your offset.
Note that EditorGUIUtility.pixelsPerPoint is not constant. It is the most up to date value possible and my even be different on different connected displays.