Skip to content

Instantly share code, notes, and snippets.

@mminer
Created October 7, 2021 21:20
Embed
What would you like to do?
Gets a reference to the main Unity editor window.
static Object GetMainEditorWindow()
{
var containerWindowType = typeof(EditorWindow).Assembly.GetType("UnityEditor.ContainerWindow");
var showModeField = containerWindowType.GetField("m_ShowMode", BindingFlags.Instance | BindingFlags.NonPublic);
return Resources
.FindObjectsOfTypeAll(containerWindowType)
.First(window => (int)showModeField.GetValue(window) == 4);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment