Skip to content

Instantly share code, notes, and snippets.

@kalineh
Created April 28, 2017 18:15
Show Gist options
  • Save kalineh/ac8140accc38a26fbc63b4ade81729a8 to your computer and use it in GitHub Desktop.
Save kalineh/ac8140accc38a26fbc63b4ade81729a8 to your computer and use it in GitHub Desktop.
Toggle game window maximized state (ctrl+M).
using UnityEditor;
using System.Reflection;
namespace FunktronicLabs
{
#if UNITY_EDITOR
public class EditorMaximizeGameWindow
{
[MenuItem("Tools/Maximize Game Window %M")]
public static void MaximizeGameWindow()
{
var assembly = Assembly.GetAssembly(typeof(Editor));
var type = assembly.GetType("UnityEditor.GameView");
var property = type.GetProperty("maximized");
var window = EditorWindow.GetWindow(type);
var maximized = (bool)property.GetValue(window, null);
property.SetValue(window, (object)(!maximized), null);
}
}
#endif
}
@dimmduh
Copy link

dimmduh commented Dec 24, 2019

Thank you, but It does not work on undocked window

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment