Okay, so this one is a little tricky, so let me break down the reason I’m trying to do this- that way if somebody has a better solution than what I’m trying to do, they can let me know.
I’m creating a generic “Patrol Path” class that can be attached to any AI. Right now you can create any number of paths and nodes for an AI unit. That all works great. Here’s the twist: At each node, I want to specify any number of actions that are specific to particular AI types only. All of my AI behavior derives from a single “AIBehavior” MonoBehaviour class… so they will all share a base class.
My plan was to have an array, or enum, or something along those lines that could list out the possible actions that are specific to that type of AI. So if I have an AI behavior called gorilla, there might be an action called ‘EatBanana’. If the same patrol class is applied to a lion, he would have a different set of actions listed, like ‘Roar’.
I’ve built out an editor class that extends Editor, and my goal is to have a GUILayout dropdown/popup for all of my node actions.
My first attempt was a failure- I did some hacky thing where I used GetComponent on the derived AI Behavior class, and stored it as PatrolBehavior (the base class)- since when PatrolPath is attached, it has no way of knowing which derived class it’s using.
So yeah… I realize that I may be going about this the wrong way, which is why I explained what I’m trying to do. If there’s a way to do it, that’s awesome- if I need to take it in a different direction to achieve the same results, that’s okay too.
One thing I don’t want to have to do is essentially have duplicate copies of my PatrolPath and PatrolPathEditor for every type of AI that I’m using.
Thanks in advance for any replies!