Search Issue Tracker
Fixed
Fixed in 2023.2.5f1, 2023.3.0a10, 7000.0.0a1
Votes
0
Found in
2023.2.0a14
2023.3.0a1
7000.0.0a1
Issue ID
UUM-34515
Regression
No
[Windows] moving window with .position across monitors with multiple dpi has the wrong size
When setting the position/size of a windows with .position, if the new place is on a screen that have a different DPI it will not get the right size. You sometime need to set the position twice to move it to the expected position
You can test it with the following code which is a modified version of [https://docs.unity3d.com/ScriptReference/EditorWindow-position.html]
{code:java}
// The position of the window is displayed when it is
// external from Unity.
using UnityEngine;
using UnityEditor;
public class PositionExample : EditorWindow
{
Vector2Int p1;
Vector2Int p2;
bool showBtn = true; [MenuItem("Examples/position")]
static void Init()
{
GetWindow<PositionExample>("position");
} void OnGUI()
{
Rect r = position;
GUILayout.Label($"Position: {r.x}x{r.y}({r.width}-{r.height})"); p1 = EditorGUILayout.Vector2IntField("Set the position:", p1);
p2 = EditorGUILayout.Vector2IntField("Set the size:", p2);
if (showBtn)
{
if (GUILayout.Button("Accept new position"))
{
r.x = p1.x;
r.y = p1.y;
r.width = p2.x;
r.height = p2.y; position = r;
}
}
}
} {code}
set it to a position on the first screen with a size of 640x480 and then change the position to appear on the second screen. The size will not be the good one.
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
- Mono Windows Builds don't produce full log callstacks when generating logs
- AssetBundles fail to load when running in Built Players for Mobile Devices
- UI elements with text gets bigger and grey when Player window is moved to another screen with different resolution
- System name accepts multiline text but crops it on confirmation, duplicates input, and shrinks the field when empty
- UI element scale and position are wrong in project build when DRS is changed with HDR and Software Dynamic Resolution enabled
Resolution Note:
Bug Resolution - [Windows] moving window with .position across monitors with multiple dpi has the wrong size. This has a linked issue of [Windows] moving window with .position across monitors with multiple dpi has the wrong position values. We plan to address this issue if a more compelling case comes up for it.
Resolution Note (fix version 2023.3.0a10):
Bug Resolution - [Windows] moving window with .position across monitors with multiple dpi has the wrong size
Resolution Note (fix version 2023.2.5f1):
Bug Resolution - [Windows] moving window with .position across monitors with multiple dpi has the wrong size