I’m somewhat new to Unity so I’m not even sure if I’m approaching the design of this in an effective way or not, but…
Scenario:
Open field battle, side A vs B, enemy NPCs as well as static gameobject objectives (think placeable gun turrets etc).
I have a script TargetableType that I can place on any gameobject on the map, they are simply a collider and Enum as a description of the type.
Next is a BattlePlan class which is TargetableType and an Enum decription.
Next is BattlePlanOrders which is List.
In the editor I assign BattlePlanOrders script to an NPC prefab, then I want to add elements to that list and be able to select the BattlePlan description, and drag/drop in a gameObject that has TargetableType on it.
For example:
Create gameObject on the map and make it TargetableType - RallyPoint.
Create gameOjbect on the map and make it TargetableType - GunTurret
Then in the editor on an NPC prefab, add the BattlePlanOrders script which is a serializable List.
In the Editor, add elements to the BattlePlanOrders list
Each element would then be 2 fields:
- Drag/drop in the gameobject with the TargetableType script on it
- Select from a drop down (Enum) for the action.
So I end up with logically something like this:
element1 - GOTO RallyPoint
element2 - ATTACK GunTurret
I can’t seem to be able to serialize this to the editor. Based on my research so far it doesn’t look like serialization supports my class structures.
My next thought was to turn BattlePlan into a scriptable object, and for each scene/scenario, create the many individual BattlePlan objects to then drop onto the elements of an assigned BattlePlanOrders script.
But it doesn’t feel like I’m doing this the right way.
Maybe to sum this up differently…
I want to be able to assign a list of gameObject targets, with a custom type of action (Enum) to a prefab at design time.