Saxi
March 15, 2015, 8:40am
1
How do I open an editor window to the middle of the screen?
I can’t seem to find the width/height of the Unity Editor itself so I can set the position properly when opening a window.
I am creating my own custom EditorWindow which I want to open dead center of the editor.
Kona
March 15, 2015, 10:13am
2
I Think you can use the Screen class.
Try something like,
public Vector2 windowSize;
public YourEditorWIndowName() {
windowSize = new Vector2( 500f, 500f );
}
public void SomeMethod() {
position = new Rect( (Screen.width * .5f) - (windowSize.x * .5f), (Screen.height * .5f) - (windowSIze.y * .5f), windowSize.x, windowSize.y );
}
Saxi
March 15, 2015, 3:11pm
3
Kona:
I Think you can use the Screen class.
Try something like,
public Vector2 windowSize;
public YourEditorWIndowName() {
windowSize = new Vector2( 500f, 500f );
}
public void SomeMethod() {
position = new Rect( (Screen.width * .5f) - (windowSize.x * .5f), (Screen.height * .5f) - (windowSIze.y * .5f), windowSize.x, windowSize.y );
}
Screen seems to refer to the Game View’s window, not Unite.exe Editor’s size.
I can’t seem to find a way to center a window in Unity.exe.