title: How to spawn units using DOTS?
body: <p>I am following this talk <a href="https://www.youtube.com/watch?v=BNMrevfB6Q0" rel="nofollow noreferrer">https://www.youtube.com/watch?v=BNMrevfB6Q0</a> and try to understand how to spawn units as I click my mouse (for testing purposes).</p>
  
  <p>For this in general, I created a UnitBase etc. which implements IConvertGameObjectToEntity::Convert to make sure all units can be converted to a Entity objects and looks like this:</p>
  
  <pre class="lang-cs prettyprint-override"><code>namespace Units
  {
      public abstract class UnitBase : MonoBehaviour, IConvertGameObjectToEntity
      {
          public float health;
  
          public bool selected;
  
          public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
          {
              dstManager.AddComponentData(entity, new Translation {Value = transform.position});
              dstManager.AddComponentData(entity, new Rotation {Value = transform.rotation});
              dstManager.AddComponentData(entity, new Selected {Value = selected});
              dstManager.AddComponentData(entity, new Health {Value = health});
          }
      }
  
      public abstract class MobileUnitBase : UnitBase
      {
          public float speed;
  
          public new void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
          {
              base.Convert(entity, dstManager, conversionSystem);
              dstManager.AddComponentData(entity, new Speed {Value = speed});
          }
      }
  }
  </code></pre>
  
  <p>These are the main components:</p>
  
  <pre class="lang-cs prettyprint-override"><code>namespace ECS.Components
  {
      public class Health : IComponentData
      {
          public float Value;
      }
  
      public class Speed : IComponentData
      {
          public float Value;
      }
  
      public class Selected : IComponentData
      {
          public bool Value;
      }
  }
  </code></pre>
  
  <p>Now, in my Test script I have this:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class Test : MonoBehaviour
  {
      public GameObject unitPrefab;
  
      private EntityManager _entityManager;
      private Entity _unitEntityPrefab;
  
      // Start is called before the first frame update
      void Start()
      {
          _entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
          _unitEntityPrefab  = GameObjectConversionUtility.ConvertGameObjectHierarchy(unitPrefab, World.Active);
      }
  
      // Update is called once per frame
      void Update()
      {
          if (Input.GetMouseButtonDown(0))
          {
              SpawnUnit(15, 15);
          }
      }
  
      private void SpawnUnit(float x, float z)
      {
          Debug.Log($"Spawning unit at  x:{x} y:{z}");
          var unitEntity = this._entityManager.Instantiate(this._unitEntityPrefab);
          _entityManager.SetComponentData(unitEntity, new Translation {Value = new Vector3(x, 1, z)});
          _entityManager.SetComponentData(unitEntity, new Rotation {Value = Quaternion.Euler(0, 0, 0)});
          _entityManager.SetComponentData(unitEntity, new Health {Value = 100f});
          _entityManager.SetComponentData(unitEntity, new Selected {Value = false});
      }
  }
  </code></pre>
  
  <p>Where unitPrefab is just a simple GameObject that has a Capsule on it and a, basically empty, script which is empty for now:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class UnitScript : UnitBase
  {
      // Start is called before the first frame update
      void Start()
      {
  
      }
  
      // Update is called once per frame
      void Update()
      {
  
      }
  }
  </code></pre>
  
  <p>The thing is, as I click, the entities get created but the unit is not rendered.</p>
  
  <p>Obviously I am missing something but I don't see what it is.</p>
  
  <p>Any help would be much appreciated!</p>