Search Unity

Instantiate hybrid from ComponentSystem

Discussion in 'Entity Component System' started by kro11, Jan 20, 2020.

  1. kro11

    kro11

    Joined:
    Sep 23, 2019
    Posts:
    105
    Is it possible to instantiate "Converted and Injected" entity + gameobject from CompnentSystem?
     
    Srokaaa likes this.
  2. BackgroundMover

    BackgroundMover

    Joined:
    May 9, 2015
    Posts:
    224
    Well you can create the Convert And Inject monobehaviour from inside the ComponentSystem code
    Code (CSharp):
    1.         var g = new GameObject();
    2.         var c = g.AddComponent<ConvertToEntity>();
    3.         c.ConversionMode = ConvertToEntity.Mode.ConvertAndInjectGameObject;
    But if you want to keep track of which entity is created by the convert component, I think that would take extra work, compared to just creating the entity yourself right?
    var e = EntityManager.CreateEntity()