Custom Editor for Interface/Child classes not displaying

Hello everyone! I am currently trying to make a custom editor that all of my AI types will see. I have an AI interface called IAI which several classes derive from. Now, I did try setting the "bool editorForChildClasses to true but this did not work either. The inspector for all of my AI types remained unchanged. My child classes are Monobehaviour classes as well.

Now, I do know that interfaces are generally a big pain in the butt on Unity, so if that is the case I might have to try something else. Any help on getting an editor that would work for all of my AI types would be fantastic.

Thanks everyone!

My AI Interface:

public interface IAI
            {
                ReadOnlyCollection<AIStates.IAIState> AIStateCollection
                {
                    get;
                }

                float MaxSpeed
                {
                    get;
                }
                Transform PathingTarget
                {
                    get; set;
                }
                Pathfinding.TargetMover TargetMover
                {
                    get; set;
                }
                AILerp AILerp
                {
                    get; set;
                }
                AIStates.IAIState CurrentAIState
                {
                    get; set;
                }

                AITypes AIType
                {
                    get;
                }

                void SetNewAIState(AIStates.AIStates state);
            }

My Editor:

[CustomEditor(typeof(AI.AITypes.IAI), true)]
        public class AIEditor : Editor
        {
            private SerializedObject m_Object;

            public void OnEnable()
            {
                m_Object = new SerializedObject(target);
            }

            public override void OnInspectorGUI()
            {
              Rect textBox = GUILayoutUtility.GetRect(0.0f, 35.0f, GUILayout.ExpandWidth(true));
                GUI.Box(textBox, "The Inspector will enable you to edit individual states.");
            }
}

Example child class

public class Chef : MonoBehaviour, IAI
            {
                  // Code here
            }

Hi @Spartiate0033! The problem is that the CustomEditor attribute only works with, MonoBehaviour- or ScriptableObject-derived classes. You cannot specify an interface or an open generic type. You would need to have something like:

class AIBehaviour : MonoBehaviour, AI.AITypes.IAI
{
    // your code here
}

and correspondingly,

[CustomEditor(typeof(AIBehaviour), true)]
class AIEditor : Editor
{
    // your code here
}

For displaying additional info for my interfaces, I’m using following code.

It’s not ideal, but works well when I don’t want to create separate abstract class for each interface combination.

public class MyBehaviour : MonoBehaviour, IMyInterface
{
    public float SomeValue;
    protected MyInterfaceInspectorInfo m_info;
}

[Serializable]
public struct MyInterfaceInspectorInfo
{
}

[CustomPropertyDrawer(typeof(MyInterfaceInspectorInfo))]
public class MyInterfaceInspectorInfoDrawer : PropertyDrawer
{
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        var target = property.serializedObject.targetObject as IMyInterface;
        // TODO: Your drawing code here
    }
}