I’m not quite sure what you mean. We are not creating any units in UnitActionSystem
. We only have a reference to the selected Unit. If you can be a little more specific, I can answer your question better.
Oh, and welcome to the community
EDIT Are you referring to Hugo dragging the unit game object into the ‘Selected Unit’ field in the inspector? If so, this is just a nice perk of Unity. Unity sees that the unit gameobject has the Unit
component and assigns the Unit
component to the field, instead of the game object. If the unit game object did not have a Unit
component, Unity would not allow you to assign the game object to the field because it cannot find a component that matches Unit
You can see here that the ‘Unit’ game object is assigned, but the type it assigned is Unit
(the part in brackets is the type). It shows ‘Name (Type)’