Search Unity

Question How do you add components to a system (through SystemHandle) from a Baker?

Discussion in 'Entity Component System' started by davenirline, Nov 4, 2022.

  1. davenirline

    davenirline

    Joined:
    Jul 7, 2010
    Posts:
    987
    My aim is to convert a ScriptableObject into data that is held in a component associated to a system. However, the Baker class doesn't seem to have its own EntityManager so I can't call methods like EntityManager.GetComponentData<T>(SystemHandle).
     
  2. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,761
    you can't really.

    systems don't exist until runtime.
     
    davenirline likes this.
  3. WAYNGames

    WAYNGames

    Joined:
    Mar 16, 2019
    Posts:
    992
    Wouldn't a singleton entity be enough?
    Convert the scriptable object to a component and add it to the entity in your baker
    Then the systems that needs that data can require the singleton entity.
     
  4. davenirline

    davenirline

    Joined:
    Jul 7, 2010
    Posts:
    987
    This is my current solution. I thought that a component associated to a system might be a better fit.
     
  5. davenirline

    davenirline

    Joined:
    Jul 7, 2010
    Posts:
    987
    I see.