Unit Spawned
public static event UnitAction UnitSpawned
This static event fired every time when any unit was spawned.
Example
For example, you can do something when any unit spawned. You can receive info about spawn by connecting to Unit.UnitSpawned
event.
using InsaneSystems.RTSStarterKit; // don't forget this directive if your script not in InsaneSystems.RTSStarterKit namespace.
// this example code can be run from any MonoBehaviour script
void Start()
{
Unit.UnitSpawned += OnUnitSpawned; // now every time when any unit being spawned, OnUnitSpawned method will be called and...
}
void OnUnitSpawned(Unit unit)
{
Debug.Log("Spawned a new unit" + unit.name); // ... this message will appear in Console.
}
void OnDestroy()
{
Unit.UnitSpawned -= OnUnitSpawned; // since this is static event, do not forget to unsubscribe!
}