- Home /
Question by
jerome-lacoste · Oct 30, 2014 at 03:40 PM ·
editoreditor-scripting
How to minimize the main editor Window by script
I am trying to work-around a FPS issue in the editor on my build server that seems to disappear when the window is minimized. Is there a way to programmatically minimize the main editor window?
I tried
EditorApplication.ExecuteMenuItem("Window/Minimize");
but it doesn't work (I reported an issue). I don't seem to be able to use SendKeys either. Any idea ?
Comment
Answer by jerome-lacoste · Oct 30, 2014 at 05:31 PM
Found a way by disassembling the UnityEditor DLL.
private static void MinimizeEditorWindow () {
// doesn't work #643951
// EditorApplication.ExecuteMenuItem("Window/Minimize");
System.Reflection.Assembly assembly = typeof(UnityEditor.EditorWindow).Assembly;
Type T = assembly.GetType("UnityEditor.ContainerWindow");
PropertyInfo PI = T.GetProperty("windows", BindingFlags.Static | BindingFlags.Public);
System.Object[] windows = (System.Object[]) PI.GetValue(null, null);
MethodInfo Minimize = T.GetMethod("Minimize");
System.Object Res = Minimize.Invoke(windows[0],null);
}
Your answer
Follow this Question
Related Questions
How to record hideFlags for Undo/Redo 0 Answers
Editor MouseDrag issues 2 Answers
Changes to Object made in custom Editor Window don't persist 0 Answers
How do you save changes made with custom editor? 3 Answers
ShaderGraph-like EditorWindow 0 Answers