Search Issue Tracker

Fixed

Fixed in 2023.2.5f1, 2023.3.0a10, 2024.1.0a1

Votes

0

Found in

2023.2.0a14

2023.3.0a1

2024.1.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. 

  1. 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.

  2. Resolution Note (fix version 2023.3.0a10):

    Bug Resolution - [Windows] moving window with .position across monitors with multiple dpi has the wrong size

  3. Resolution Note (fix version 2023.2.5f1):

    Bug Resolution - [Windows] moving window with .position across monitors with multiple dpi has the wrong size

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.