Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

GetComponentDataFromEntity in JobComponentSystem ForEach

Discussion in 'Entity Component System' started by alexandre-fiset, Feb 7, 2020.

  1. alexandre-fiset

    alexandre-fiset

    Joined:
    Mar 19, 2012
    Posts:
    702
    Is this by design that we can't pass GetComponentDataFromEntity into a burst and jobbed ForEach?

    I wonder what is the point of the "read only" parameter of the GetComponentDataFromEntity method if we anyway need the [ReadOnly] attribute on the variable for it to work properly.

    Right now I get this error:

    Code (CSharp):
    1. InvalidOperationException: <>c__DisplayClass_OnUpdate_LambdaJob0.Data.completed is not declared [ReadOnly] in a IJobParallelFor job. The container does not support parallel writing. Please use a more suitable container type.
     
  2. alexandre-fiset

    alexandre-fiset

    Joined:
    Mar 19, 2012
    Posts:
    702
    Ok so just found out about this:

    Code (CSharp):
    1. Entities.WithReadOnly(variable)
    Leaving it here for others.
     
  3. Lucas-Meijer

    Lucas-Meijer

    Unity Technologies

    Joined:
    Nov 26, 2012
    Posts:
    175
    We were working on supporting GetComponent<YourComponent>(entity) support today, so you can write that in your lambda amd don’t have to manually do the getcomponentdatafromentity thing. Coming to a release soon(tm)
     
  4. nicolasgramlich

    nicolasgramlich

    Joined:
    Sep 21, 2017
    Posts:
    231
    Yeesssss! :D
     
  5. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,029
    Will it support getting classic component (EntityManager.GetComponentObject<Transform>(entity)) too? I also need that feature.
     
  6. Lucas-Meijer

    Lucas-Meijer

    Unity Technologies

    Joined:
    Nov 26, 2012
    Posts:
    175
    probably not in the first release, but extending support to dynamicbuffer, managed objects, basically all componenttypes makes a lot of sense,
     
  7. elJoel

    elJoel

    Joined:
    Sep 7, 2016
    Posts:
    125
    This is not out yet right?
     
  8. brunocoimbra

    brunocoimbra

    Joined:
    Sep 2, 2015
    Posts:
    677
    It is, just use SystemBase + Entities.ForEach instead of ComponentSystem/JobComponentSystem
     
    Lukas_Kastern likes this.
  9. elJoel

    elJoel

    Joined:
    Sep 7, 2016
    Posts:
    125
    oh wow ok SystemBase seems to be the new way to go for all systems. Thanks
     
    brunocoimbra likes this.