Search Unity

Does anyone know how to pass data from entity world to classic one?

Discussion in 'Entity Component System' started by xVergilx, Jan 28, 2019.

  1. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    Title. I'm looking for some approach to transfer data from the job systems to the default Unity. (E.g. data for UI)
    Will something like UniRx work?
    E.g. passing the data to the main thread dispatcher that will process it after that in the main thread (via static call)?

    Any gotchas except that burst won't work?
     
    Last edited: Jan 28, 2019
  2. M_R

    M_R

    Joined:
    Apr 15, 2015
    Posts:
    559
    either use a ComponentSystem with Hybrid setup (GameObjectEntity)
    or store the Entity in a MonoBehaviour and fetch the components with EntityManager.GetComponentData<T>(entity);

    are you totally sure that the dispatcher itself is thread-safe? even if it is, if it uses locks the performance may be worse that single-thread
     
    xVergilx likes this.
  3. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    Right, GetComponentData<T> is probably the way, but I'd rather prefer something reactive.
    Dispatcher is thread safe, I've already used it for sending events between threads. Not sure about the locks tho, might need to investigate that.