Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Docking Editor Window from Script

Discussion in 'Immediate Mode GUI (IMGUI)' started by Deleted User, Oct 13, 2016.

  1. Deleted User

    Deleted User

    Guest

  2. PsyKaw

    PsyKaw

    Joined:
    Aug 16, 2012
    Posts:
    102
    You can use Relfection to get inspector type like this :
    Code (CSharp):
    1. Type inspectorType = Type.GetType("UnityEditor.InspectorWindow,UnityEditor.dll");
    2. EditorWindow window = EditorWindow.GetWindow<T>(new Type[] {inspectorType});
     
  3. Deleted User

    Deleted User

    Guest

    That works. Thanks!
     
  4. Loden_Heathen

    Loden_Heathen

    Joined:
    Sep 1, 2012
    Posts:
    480
    I know this is older but ran across it when looking for a similar answer.
    As to the above why wouldn't you simply call
    Code (CSharp):
    1.  
    2. var inspectorType = typeof(UnityEditor.InspectorWindow);
    3.  
     
    marcospgp likes this.
  5. SisusCo

    SisusCo

    Joined:
    Jan 29, 2019
    Posts:
    1,266
    @lodendsg
    That is because InspectorWindow is an internal class, so it is not visible to scripts outside the UnityEditor assembly. Type.GetType can however be used to bypass this restriction and manually retrieve the type from the assembly.
     
    unitybru likes this.
  6. Loden_Heathen

    Loden_Heathen

    Joined:
    Sep 1, 2012
    Posts:
    480
    Ah gotcha ... never tried withi InspectorWindow, always aim as Scene or Game
     
  7. 8bitgoose

    8bitgoose

    Joined:
    Dec 28, 2014
    Posts:
    448
    This was super helpful and exactly what I needed.

    Anyone know the internal class for the console? I want to dock something next to the console and I can't figure out what the class name is. Would be nice if Unity made a document to list this so we can easily dock stuff next to things.
     
  8. SisusCo

    SisusCo

    Joined:
    Jan 29, 2019
    Posts:
    1,266
  9. 8bitgoose

    8bitgoose

    Joined:
    Dec 28, 2014
    Posts:
    448
    SisusCo likes this.
  10. 8bitgoose

    8bitgoose

    Joined:
    Dec 28, 2014
    Posts:
    448
    I figured it out!

    var window = EditorWindow.GetWindow<T>("Name Of Custom Window", true, System.Type.GetType("UnityEditor.ConsoleWindow,UnityEditor.dll"));


    I had UnityEngine instead of UnityEditor in there too which threw it off till I fixed it. Now the window docks perfectly!
     
    shelim and snuhhuhuhuh like this.