Custom inspector of a base class

I’d like to fold out the base class items in the inspector with the code below.
I want a child class inspector to show a “common” foldout for the base class items followed by the items unique to the child class - how do I do that?

using UnityEngine;
using UnityEditor;
using System.Collections;

[CustomEditor (typeof(ServerObject))]
public class ServerObjectCustomInspector : Editor
{
	bool folded;
	
	public override void OnInspectorGUI()
	{
		folded = EditorGUILayout.Foldout(folded, "Common");
		if (folded)
	            DrawDefaultInspector ();
			
		if (GUI.changed)
			EditorUtility.SetDirty (target);
	}
}

You can use the “is” operator in the code to check if the object is an instance of the subclass:-

public class SubClass : MainClass {
  ...
}

...

if (target is SubClass) {
  // Additional GUI.
}

Thanks Andeeeeee.

I’ve been trying to do something like this lately but I can’t even get the editor to work for a subclass. I’m assuming it’s due to the type defined in the editor being the superclass?

Do I also need to subclass the editor for each subclass of the object edited? Not sure how to get the editor to recognize the subclassed items too.

This and making custom inspector doesn’t work with scriptable objects, only with mono.