I have a custom inspector for a class that display some variables, and then has a reference to some other object (say, a ScriptableObject for example). This custom inspector will then also display an inspector for this referenced object by doing the well-known iteration over it:
var serializedObj = new SerializedObject(referencedObject);
var iterator = serializedObj.GetIterator();
if (iterator.NextVisible(true))
{
do
{
EditorGUILayout.PropertyField(iterator);
}
while (iterator.NextVisible(false));
}
serializedObj.ApplyModifiedProperties();
Now, say that the referenced object actually had a custom editor script for it. The code above won’t invoke it and instead it will display a default inspector. Is there any way to tell Unity to inspect an object like with PropertyField, except that instead of inspecting a SerializedProperty it will inspect a SerializedObject and therefore respect the custom inspector scripts same as SerializedProperty respects the custom property drawers?