Extending Mesh Renderer Component with a custom Editor

I would like to add some fields to what I see in the custom editor of a Mesh Renderer component. So I started by simply doing this:

[CustomEditor(typeof(MeshRenderer), true)]
public class MeshRendererEditor : Editor
    {
    public override void OnInspectorGUI()
        {
        // Show default inspector property editor
        DrawDefaultInspector();
        }

I was hoping that would essentially show me the exact view that I had prior to adding the custom editor. This is not the case, what I see is:

But what I had as default was this:
6188850--678486--Capture2.PNG

There are obvious formatting changes. With things grouped into collapsable sections. But there are also missing parameters like lightmap Parameters which is empty in the default view.

I don’t really care to recreate the wheel to try to have the same view as the default before a custom editor is provided, is there a way to

  1. Draw the default as it is shown without a custom editor plugged in?
  2. Code that is used by Unity to draw the editor for Mesh Renderer exactly as the default looks?

up

Does this help?

1 Like

Maybe. this certainly would have been helpful:
https://github.com/jamesjlinden/unity-decompiled/tree/master/UnityEditor/UnityEditor

hi the solution is mix the last two links.

replacing the function OnEnable with :

    void OnEnable()
    {
        defaultEditor = CreateEditor(targets, Type.GetType("UnityEditor.MeshRendererEditor, UnityEditor"));
        _TargetMeshRenderer = target as MeshRenderer;
    }