Hello I have an issue related on how I'm using my Scriptable Objects and the way I'm trying to show their information on the UI.
As now I have a Tower class:
public class Tower : Building, IInitializable, IStatDriver
{
[field: SerializeField] public TowerConfig TConfig { get; private set; }
[field: SerializeField] public StatDriver CurrentStats { get; private set; }
}
And it's config:
public class TowerConfig : BuildingConfig, IHasStats
{
[field: SerializeField] public BaseStats BaseStats { get; private set; }
[field: SerializeField] public Troop Troop { get; private set; }
[field: SerializeField] public TowerSpawnStrategy SpawnStrategy { get; private set; }
}
And the troop class:
public class Troop : MonoBehaviour, IStatDriver
{
[field:SerializeField] public TroopConfig TConfig { get; private set; }
[field: SerializeField] public StatDriver CurrentStats { get; private set; }
}
Since the StatDriver (where the dictionary with the instance values of the troop is) initializes when the tower actually spawns the troop, I can't show the troop information on the UI when I click on it, as the dictionary is null.
Is it ok if I instantiate an inactive troop for each tower I spawn so I can always have the initialized dictionary at hand, updating it as I update the Level stat of my tower (the instance stats of the troop depends on the level of the tower).