- Home /
 
 
               Question by 
               Gamingdrake · Mar 02, 2014 at 10:39 PM · 
                listinspectorcustom-inspectorpolymorphism  
              
 
              Show DefaultInspector on child classes in list
First off, let me say that I know Unity doesnt support polymorphism.
Thats my problem.
Here is my proposed solution, but also my question. Is there a way to tell Unity to draw the default inspector for the object of type "GetType()", or chain the draw methods without me having to write a custom inspector for each child object? Refer to the code below.
 public override void OnInspectorGUI()
     {
 
         if (m_Instance == null)
             return;
 
         this.DrawDefaultInspector();
 
         foreach(BaseClass bc in m_Instance.ListOfChildClasses)
                bc.DrawDefaultInspector(); //question here
   
         //I have also tried Editor.CreateEditor(bc).OnInspectorGUI() <- requires me 
         //to create custom editors for all the children. I just want the default
         //editor for the child class, given that I can get its type in the custom
         //inspector that contains the list
 
     }
 
               My end goal is to make a scriptable object that allows me to modify a list of "Behaviors" based on what the user selects for the properties of the object. The behaviors would be added/removed to a list as the fields get modified. This might need clarification, so let me know if clarification would help.
               Comment
              
 
               
              Your answer