Search Unity

Manually Open custom inspector for serializable object

Discussion in 'Immediate Mode GUI (IMGUI)' started by hexdump, Mar 11, 2016.

  1. hexdump

    hexdump

    Joined:
    Dec 29, 2008
    Posts:
    443
    Hi,

    I have a window editor that holds nodes. I would like to open a custom inspector when one of these nodes is selected. The node class is a custom serializable class. Is this possible?.

    I would like to achieve the same behaviour that we have when we select a gameobject in sceneview that inmediately show properties for the object (Components, etc...) in the unity inspector.

    Cheers.
     
  2. skalev

    skalev

    Joined:
    Feb 16, 2012
    Posts:
    264
  3. hexdump

    hexdump

    Joined:
    Dec 29, 2008
    Posts:
    443
    Hi,

    I think I can't use that.My classes do not inherit from UnityEngine.Object or Transform. They are just serializable because as I said I'm not working inside sceneview but an editor window.

    Cheers
     
  4. skalev

    skalev

    Joined:
    Feb 16, 2012
    Posts:
    264
    In that case, you'll have to create an object for the inspector to look at.

    If you intend on showing this in the normal inspector window, you can wrap your object in a serializedObject, and then set that to be the selected object.

    If you just want to draw the object in your own window, you can use Editor.CreateEditor() to get an instance of the inspector used, and then call its OnInspectorGUI() function in your own window's GUI function.

    In any case, the trick here is to use the SerializedObject, this is how unity draws your classes.