Creating Battle Plan Orders at design time in the editor - serialization or SO's or?

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:

  1. Drag/drop in the gameobject with the TargetableType script on it
  2. 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.

[Serializable]
public class BattleOrder {
   public string commandAction;
   public string targetSearchString;
}

public class BattlePlan : ScriptableObject {
  public BattleOrder[] battleOrders;
}

I’ve made some progress. What this is starting to turn into is somewhat of a scenario editor/map setup which I’ll explore and research more later. For now I still don’t get the serialization I’d like to see in the editor.

What I have so far:

For any static gameobject on the map (capture point, destructable obstacle, enemy gun tower etc), I add the TargetableType script:

NOTE that I’ve removed class methods and other private properties.

[System.Serializable]
public class TargetableType : MonoBehaviour
{
    [SerializeField] private Collider targetReachedCollider;
    [SerializeField] private ETargetableType targetableTypeEnum;
}

[System.Serializable]
public enum ETargetableType
{
    NONE,
    COVER,
    ENEMY_SOLIDER,
    ENEMY_VEHICLE,
    ENEMY_AIR,
    ENEMY_SEA,
    ENEMY_STATIC_DEFENSE,
    RALLY_POINT, // easy to use target to run to after spawning in
    CAPTURE_POINT
}

In the inspector:

That all works/looks the way I want.

This is how I would like to build up classes but things don’t serialize in the way I’d like.

Add a new GameObject that contains my BattlePlanOrders, which are lists of BattlePlans, where each BattlePlan contains a TargetableType and BattlePlan action.

[System.Serializable]
[System.Serializable]
public class BattlePlanOrders : MonoBehaviour
{
    public List<BattlePlanOrder> Orders;
}

public class BattlePlanOrder : MonoBehaviour
{
    public TargetableType BattlePlanOrderTarget;
    public EBattlePlanOrderAction BattlePlanOrderAction;
}

[System.Serializable]
public enum EBattlePlanOrderAction
{
    GOTO,
    ATTACK_AREA,
    DEFEND,
    DESTROY
}

If I add BattlePlanOrders to a gameobject, this is what I get in the inspector:

This does work if I place a BattlePlanOrder script on a gameobject, then drag in the TargetableType already on the gameobject, and select the BattlePlan action, eg:

However, this now involves extra steps of having to add both the TargetableType and BattlePlanOrder to each gameobject that I then drag into the list of BattlePlanOrders.

What I’d really like to do, is add the BattlePlanOrders script to a gameobject, manually set the index that creates the desired number of elements, then drag/drop TargetableType objects into and select the action for each one.

That would mean:

  • TargetableType is on a game object
  • BattlePlanOrders is on a game object
  • BattlePlanOrder is not on a game object

I can at least move forward with the one approach that functions but appreciate any advice on improvements, or any pointers on where to read up on building up more involved scenario editors.

Thanks.

EDIT: trying to figure out how to link images from imgbb.com - sorted out, needed to use direct links.