I have a List of BaseObject , from which several classes inherit like Unit for my player units, Obstacle for world obstacles, Interactable for interactable objects, etc. I use the list to select the BaseObjects in my scene which correspond to a specific objective that I want the player to complete. I classify my objectives with an enum ObjectiveType, and only one inherited class type should be selectable for each enum value. However, since they all all inherit BaseObject, they all show up in the list at all times, leading to potential errors when building my levels.
Is there a way to place a SearchContext attribute on the list, and then change it based on the type of objective I have via an enum? Something like this:
public enum ObjectiveType { type1, type2, type3}
public ObjectiveType objectiveType;
public string objectiveTypeName => objectiveType.ToString();
[SearchContext($"t:{objectiveTypeName}")]
public List<BaseObject> baseObjectList;
I know an alternative method would be to create a unique list for each inherited class, but I’d like to avoid that if possible to keep my code simpler.