Forum Discussion
zwickarr
12 years agoHonored Guest
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()
}
2 Replies
Replies have been turned off for this discussion
- drashHeroic ExplorerHey, this is a great script, thank you! I didn't realize it was possible to have that much control over the editor, let alone just taking the game window out onto its own screen. I'm going to have to rethink my monitor setup! All this time, I've just been building a new executable every time I want to test with the Rift. :oops:
- zwickarrHonored Guestyeah being able to test your game while in the editor is one advantage over UDK, where you do have to build. Im often changing the camera settings while in the rift. I look down through those lil vent holes :D
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 2 years ago