title: Custom Editor Inheritance in Unity
body: <p><strong>SOLVED</strong>, the fix is in the code</p>
  
  <p>I have some class that I want to create custom editor for, but I can't make it work.</p>
  
  <p>I classes inherit from each other, and I want that the editor for the base class would be applied to all the sub classes editors</p>
  
  <p>I have tried to use <code>[CustomEditor( typeof( BaseClassName ), true )]</code>, according to <a href="http://docs.unity3d.com/Documentation/ScriptReference/CustomEditor-ctor.html" rel="nofollow noreferrer">Unity documentation</a> it suppose to work. </p>
  
  <p>But yet, only the base class has a custom editor, and the sub classes get the custom editor I generated from them, ignoring the base class inspector. </p>
  
  <p>I have also tried to inherit from the custom editor class that I created for the base class, but it didn't work…</p>
  
  <p>Base Class:</p>
  
  <pre><code>[CustomEditor(typeof(ScriptableObjects.CharacterData), true)]
  public class CharacterEditor : Editor
  {
      private SerializedProperty characterName, characterTexture, characterNormalMap;
      private bool texturesFoldout = false;
  
      protected void OnEnable()
      {
          characterName = serializedObject.FindProperty("characterName");
          characterTexture = serializedObject.FindProperty("characterTexture");
          characterNormalMap = serializedObject.FindProperty("characterNormalMap");
      }
      public override void OnInspectorGUI()
      {
          serializedObject.Update();
          EditorGUILayout.PropertyField(characterName);
          texturesFoldout = EditorGUILayout.Foldout(texturesFoldout, "Textures");
          if (texturesFoldout)
          {
              EditorGUILayout.PropertyField(characterTexture);
              EditorGUILayout.PropertyField(characterNormalMap);
          }
          serializedObject.ApplyModifiedProperties();
      }
  }
  </code></pre>
  
  <p>Sub Class:</p>
  
  <pre><code>[CustomEditor(typeof(ScriptableObjects.SoldierData))]
  public class SoldierEditor : CharacterEditor
  {
      private SerializedProperty life, autoAttack, skills;
  
      protected new void OnEnable()
      {
          base.OnEnable();
          life = serializedObject.FindProperty("life");
          autoAttack = serializedObject.FindProperty("autoAttack");
          skills = serializedObject.FindProperty("skills");
      }
      public override void OnInspectorGUI()
      {
          // base.DrawDefaultInspector(); The mistake
          base.OnInspectorGUI(); // The FIX!
          serializedObject.Update();
          EditorGUILayout.PropertyField(life);
          EditorGUILayout.PropertyField(autoAttack);
          EditorGUILayout.PropertyField(skills);
          serializedObject.ApplyModifiedProperties();
      }
  }
  </code></pre>
  
  <p>Images:</p>
  
  <p><a href="https://i.stack.imgur.com/YHWtx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YHWtx.png" alt="The Character Custom Inspector"></a></p>
  
  <p><a href="https://i.stack.imgur.com/1116i.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1116i.png" alt="The Soldier Custom Inspector"></a></p>
  
  <p>As you can see, the textures Foldout is only in the base class</p>