Search Unity

How to get sharedComponentData in IJobChunk

Discussion in 'Entity Component System' started by kstothert, May 31, 2019.

  1. kstothert

    kstothert

    Joined:
    Dec 8, 2016
    Posts:
    68
    I'm using
    [ReadOnly] public ArchetypeChunkSharedComponentType<GoalContainer> GoalContainerType;
    to get shared component data in an IJobChunk BUT the api
    chunk.GetSharedComponentData<GoalContainer>(GoalContainerType, ENTITYMANAGER]);
    want's an entitymanager as an argument. Am i missing something?
     
  2. GilCat

    GilCat

    Joined:
    Sep 21, 2013
    Posts:
    676
    So far you can't access ISharedComponentData inside jobs. It has been said here in the forum that it will be supported in the near future, but I don't know when.
     
    kstothert likes this.
  3. kstothert

    kstothert

    Joined:
    Dec 8, 2016
    Posts:
    68
    thanks. that's really surprising though. I thought I saw some IJobParallelForFilter... or something along those lines and i assumed it was for filtering by shared component data. This throws a wrench in my plans... Is the workaround just to use ComponentSystem on the main thread or is there a method to pull the data off in OnUpdate and pass it into the job?
     
  4. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    1,154
    yes you can pass it into the job. check also here on forum, forgot the exact api... getallsharedcomponentdata or something
     
  5. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    SCD's real value is kept in a managed list in EM that's why the API wants you to provide the EM, so SCD index on each chunk could be exchaged for the value. And managed list along with EM is a reference type and cannot go into a job. I have an article about this too if you want to read something : https://gametorrahod.com/everything-about-isharedcomponentdata/ The ACSCT is still good for doing chunk.Has or .DidChange in-job.
     
    Antypodish and kstothert like this.
  6. kstothert

    kstothert

    Joined:
    Dec 8, 2016
    Posts:
    68
    Your blog is a goldmine. Do you have a patreon?
     
  7. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    Thank you, I do have one in the AUTHOR link! (or rather it's this, however I set one up for fun just because Patreon is changing business model and I want to lock in as a founder status..)