- Home /
Difference between Screen.height / width and EditorWindow.position.width / height
Hello,
I am working on developing a custom Editor tool. I would like to break the window into sections similar to that seen in the attached image. Below is the code I am using to generate the window. Setting a min and max size then setting initial position and size for the window.
public static void OpenWindow(int numberOfSlots, DockTypes typeOfDock)
{
noOfSlots = numberOfSlots;
DockEditor window = (DockEditor)EditorWindow.GetWindow(typeof(DockEditor));
window.maxSize = new Vector2(1500, 800);
window.minSize = new Vector2(500,400);
window.position = new Rect(20, 30, 1000, 400);
window.Show();
}
In theory (well in my theory :)) this should draw a window 1000 x 400 px at position 20,30. This does happen however, Screen.width is returning as 1254 and Screen.height is returning as 533 (not 1000x400). Below is an image of the window being generated. The bottom fields show the returned values for Screen.width and Screen.height (as well as EditorWindow.position.widthand EditorWindow.position.height). You can see the Screen values are higher than actual. The position values are closer but still off by a couple pixels. All values change when I manually resize the window so they are definitely being influenced by the active window and not some other window in the editor.
What am I missing about Screen.height / width and how it is represented? Why are the values different than EditorWindow.position? Why aren't the position values accurate to the pixel?