Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Question Is there a way to direct editor focus to the inspector?

Discussion in 'Code Editors & IDEs' started by robrab2000-aa, Jan 24, 2023.

  1. robrab2000-aa

    robrab2000-aa

    Joined:
    Feb 8, 2019
    Posts:
    127
    Hey, I'm able to shift editor focus over to a custom window by adding it to the menu:

    Code (CSharp):
    1.  
    2.         [MenuItem("AA_Tools/Variants/Variant Template Utility")]
    3.         private static void OpenWindow() => GetWindow<VariantTemplateUtility>().Show();
    But I can't seem to work out how to get it to do the same thing with an inspector window. Is this possible?
     
    Avalin likes this.
  2. sean244

    sean244

    Joined:
    Nov 4, 2017
    Posts:
    97
    I’m also looking for a solution to this.
     
  3. robrab2000-aa

    robrab2000-aa

    Joined:
    Feb 8, 2019
    Posts:
    127
    I was able to achieve it with this:

    Code (CSharp):
    1. public static void SelectContentListing()
    2. {
    3.     var catalogListingManager = FindObjectOfType<ContentManager>().m_ContentCatalogListingManager;
    4.     Selection.activeObject = catalogListingManager;
    5.     EditorApplication.ExecuteMenuItem("Window/General/Inspector");
    6.     EditorGUIUtility.PingObject(catalogListingManager);
    7. }
     
    sean244 likes this.
  4. sean244

    sean244

    Joined:
    Nov 4, 2017
    Posts:
    97
    Thank you so much. That worked perfectly.
     
    robrab2000-aa likes this.