How do you get the default inspector to draw for Prefabs ?

I am extending the inspector for prefabs so that I can include custom functionality.
I want to draw the regular inspector gui, in addition to my own custom gui.

However, I cannot seem to get the default inspector for Prefabs (Project Window) to draw properly. Neither DrawDefaultInspector() nor base.OnInspectorGUI() seem to work in this case.

Question: In the case of wanting to extend an existing inspector (GameObject / Prefab), how do you get the original inspector to draw ?

Reference Code:

[CanEditMultipleObjects, CustomEditor (typeof(GameObject))]
public class PrefabEditor : Editor {

	public override void OnInspectorGUI(){
		//draw regular inspector gui
		DrawDefaultInspector(); //THIS ISN'T WORKING AS EXPECTED

            //Pseudo Code
            bool isPrefab = CheckIfPrefab(target);
            if(isPrefab == false)
                 return;
		
           //Add custom gui....
       }
}

52169-prefabinspector-normal.png

52170-prefabinspector-result.png

base.OnInspectorGUI() is what you`re looking

You actually can’t extend an existing editor. Unity (or actually the InspectorWindow class) will pick one editor per object in the inspector. If you implement a custom inspector for a built-in component / object it will replace the original one.

There is a class inside the UnityEditor assembly that is called “GameObjectInspector” which implements the GUI you see at the very top of the inspector window when you select a gameobject. That class is marked as internal, so you can’t derive your own class from it. You really should not replace any of the built-in editors. You might want to implement a custom inspector for a specialized script which you attach to the prefab.

If you want every prefab to have an instance of that script you can implement an AssetPostProcessor which adds your script to each prefab. Already existing prefabs need to be reimported in that case. The script could be empty. You just use it to add your custom GUI.

You might want to downlad ILSpy and take a look at the UnityEditor.dll. It helps to understand how the editor actually works.