Created
          October 7, 2021 21:20 
        
      - 
      
 - 
        
Save mminer/1fca7d7c66567991746f24a4797e92db to your computer and use it in GitHub Desktop.  
    Gets a reference to the main Unity editor window.
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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