Screen.What?

There are two useful functions when investigating the relationship between the window showing the camera view, and the overall screen.

Screen.width is the width of “player window”. mainWindowPosition is the position of the top left corner of “the display”, this term is not defined! I had to experiment, as shown in the attached picture, to see what these terms actually meant, to then find out, they run just short of properly defining the position of the player window anyway. There must be a separate way to do this, but the vague and unclear Screen class is all I can find. Does anyone have a better place to start in the documentation to get more information?

What is your use case?

You can get additional metrics from the EditorWindow class.

The documentation is correct, but only for runtime. All of these values behave very strangely in the editor.

Screen.width and Screen.height, for example, will be the size of the currently drawing editor window if you check it from eg. inside OnInspectorGUI in a custom editor. The Game View is considered the “display” that the game window is inside. Stuff like that.

If you want information about the editor windows in Unity, you’ll need to look at all the EditorWindows and look at their position, which is a rect containing both the position and the size (lol).

Internally, Unity uses Resources.GetObjectsOfTypeAll to find the editor windows of a type that exist when you do eg. EditorWindow.GetWindow. The class GameView is internal, though, so you’ll have to do reflection to get the window, or do something like:

EditorWindow gameViewWindow = Resources.FindObjectsOfTypeAll<EditorWindow>().FirstOrDefault(w => w.GetType().Name == "GameView");
if (gameViewWindow)
{
    Debug.Log("The Game View has this rect: " + gameViewWindow.position);
}

Oh, thank you! I don’t know how I didn’t see the EditorWindow class. I was curious about looking into Unity’s windows, but could only find stuff about Windows the operating system lol and the Screen class which provided a frustratingly low amount of info in that case. Thank you