Game view set size & position
I have the Game view in a floating window on my 2nd monitor and i'm constantly had to adjust it for when running on the Rift when testing my game. So I made an editor script that sets the window size and its position. The default values work for my monitor setup but you will probably need to tweak them for your setup.
I'm no programmer, so this could do bad things but it works for me!
got most of the code from:
http://answers.unity3d.com/questions/179775/game-window-size-from-editor-window-in-editor-mode.html
I'm no programmer, so this could do bad things but it works for me!
got most of the code from:
http://answers.unity3d.com/questions/179775/game-window-size-from-editor-window-in-editor-mode.html
using UnityEngine;
using UnityEditor;
public class SetGameSizeWindow: EditorWindow {
private Vector2 _size = new Vector2(1920, 800);
private Vector2 _pos = new Vector2(7, 200);
[MenuItem ("Window/Set Game Size...")]
static void Init () {
SetGameSizeWindow window = (SetGameSizeWindow)(EditorWindow.GetWindow(typeof(SetGameSizeWindow)));
} // Init()
public static EditorWindow GetMainGameView() {
System.Type T = System.Type.GetType("UnityEditor.GameView,UnityEditor");
System.Reflection.MethodInfo GetMainGameView = T.GetMethod("GetMainGameView",System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
System.Object Res = GetMainGameView.Invoke(null,null);
return (EditorWindow)Res;
} // GetMainGameView()
void OnGUI () {
_size.x = EditorGUILayout.IntField("size X", (int)_size.x);
_size.y = EditorGUILayout.IntField("size Y", (int)_size.y);
_pos.x = EditorGUILayout.IntField("position X", (int)_pos.x);
_pos.y = EditorGUILayout.IntField("position Y", (int)_pos.y);
if (GUILayout.Button("Set")) {
EditorWindow gameView = GetMainGameView();
Rect pos = gameView.position;
Rect xypos = GetMainGameView().position;
xypos.x = _pos.x;
xypos.y = _pos.y;
pos.width = _size.x;
pos.height = _size.y;
gameView.position = pos;
GetMainGameView().position = xypos;
}
} // OnGUI()
}
