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
}