- Home /
How do I change the size & position of the standalone player in windows?
It would be really helpful to be able to change the size and position of the window of the standalone player (for windows) dynamically - does anybody know how to do that?
I'd be happy to do it with Interop to platform specific calls or private Unity classes through reflection, but I'm having trouble figuring out what class or function I can use to do the resizing and positioning
...to explain what I mean by private Unity classes, I'm able to change the GameView window position and size by using unity's private "GameView" class to get an EditorWindow that I can muck the position of with this code below:
static Type gameViewType = null;
private static Type GetGameViewType()
{
if (gameViewType == null)
{
Assembly editorAssembly = Assembly.GetAssembly(typeof(UnityEditor.EditorWindow));
foreach (Type type in editorAssembly.GetTypes())
{
if (type.Namespace != null && type.Namespace.ToString() == "UnityEditor" && type.Name == "GameView")
{
gameViewType = type;
}
}
}
return gameViewType;
}
static WeakReference<EditorWindow> gameViewWindowRef = new WeakReference<EditorWindow>();
private static EditorWindow GetGameViewWindow()
{
if (gameViewWindowRef.Target == null)
{
gameViewWindowRef.Target = EditorWindow.GetWindow(GetGameViewType());
}
return gameViewWindowRef.Target;
}
but of course that doesn't work in the standalone player, cause there are no EditorWindows...
thanks
Comment