I have a MonoBehaviour that has a ScriptableObject as a member variable. By default, the inspector shows an object field for that member variable, where I can drag in other instances. So far, so good.
In addition to this field, I’d like to place, inline in the inspector at that point, all the fields that would normally be shown if I had that ScriptableObject selected instead. Altering those values should alter the underlying ScriptableObject.
I’m familiar with writing custom editors generally. If I write a custom editor for my MonoBehaviour, is there a way in its OnInspectorGUI, that can I can say to Unity “Give me an instance of the editor for this other object”, and then “call its OnInspectorGUI function”.
Edited to add: Something like the following
class SomeData : ScriptableObject
{
public string m_text;
// Potentially many other fields here.
}
class MyBehaviour : MonoBehaviour
{
public SomeData m_data;
}
class MyBehaviourEditor : Editor
{
public override void OnInspectorGUI()
{
DrawDefaultInspector();
MyBehaviour mb = target as MyBehaviour;
Editor e = ...; // (Get an editor for mb.m_data);
e.OnInspectorGUI();
}
}