If I have a custom editor for a ScriptableObject, and the ScriptableObject has a list of interfaces inside it, what would be the best way to draw the default inspector for those objects?
–More Description Below–
I have a custom editor for a ScriptableObject asset in my project hierarchy. The asset script contains a list of ScriptableObjects that also inherit from IModuleComponent. What I want to do is display the default inspector for the embedded scriptableobjects/IModuleComponents in my custom inspector, to essentially treat the scriptableobject asset like a gameobject and then get all the components in the list to look like monobehaviors do on a gameobject.
I can get something like what I want to work by looping through the embedded components and calling an inherited function, but that requires me to write a custom IModuleComponent.DrawInInspector function for every new component.
Is there a way to get Unity to draw an inspector for each module without writing custom draw code for every module? Or if not, how would I get the custom function to look more like what Unity has?
Here is some of my code. This first snippet is my custom editor.
if (showPosition*)*
{
GUILayout.Space(10);
//EditorGUILayout.ObjectField(myTarget.componentModules as ScriptableObject, typeof(ScriptableObject), false);
(myTarget.componentModules as IComponentModule).DrawInInspector();
}
And in my component code I have this
public void DrawInInspector()
{
#if UNITY_EDITOR
suckItUnity = EditorGUILayout.Toggle(“Suck it Unity”, suckItUnity);
#endif
}
[40031-halp.png|40031]