Search Unity

IJobProcessComponentDataWithEntity and temporary array

Discussion in 'Data Oriented Technology Stack' started by Kichang-Kim, Dec 16, 2018.

  1. Kichang-Kim

    Kichang-Kim

    Joined:
    Oct 19, 2010
    Posts:
    277
    Hi, I have a question about IJobProcessComponentDataWithEntity and temporary array.

    In Boid sample, it uses NativeArray which has same size to ComponentDataArray for temporary calculation. It can be easily accessed by index in IJobParallelFor.

    But ComponentDataArray will be deprecated, and Chunk iteration or IJobProcessComponentData(WithEntity) is recommended way for writing ECS. (https://forum.unity.com/threads/per...creasing-archetype-count.567418/#post-3772273)

    So, my questions is how to get total entity count and entity index for temporary array without ComponentDataArray?
     
  2. Kichang-Kim

    Kichang-Kim

    Joined:
    Oct 19, 2010
    Posts:
    277
  3. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,261
    StartIndex disappeared now with unknown reason. I think because Unity want to make each ArchetypeChunk stand alone, in a place like IJobChunk where you get each ArchetypeChunk the StartIndex (which is a field of chunk) would not make sense. At the same time you cannot do what described in the current docs. Instead of parallel for job use IJobChunk which comes with chunk index relative to all chunks from the CG you are working on.

    ArchetypeChunkArray.CalculateEntityCount(NativeArray<ArchetypeChunk> chunks) still exist, for IJobChunk you may need to count from the main thread.
     
    Kichang-Kim likes this.