Is there any way to access the ComponentData from another entity inside IJobForEachWithEntity? From my understanding, currently there is no way to do that.
Hi just use:
ComponentDataFromEntity<MyData>
BufferFromEntity<MyBuffer>
you get both from JobComponentSystem
GetComponentDataFromEntity<MyData>()
GetBufferFromEntity<MyBuffer>()
access is then:
ComponentDataFromEntity<MyData> compdataFromEntity;
BufferFromEntity<MyBuffer> bufferFromEntity;
MyData data = compdataFromEntity[someEntity];
DynamicBuffer<MyBuffer> buffer = bufferFromEntity[someEntity];
you can set components this way:
compdataFromEntity[someEntity] = data;
but you have to add the attribute NativeDisableParallelForRestrictionAttribute to the member:
[NativeDisableParallelForRestriction] ComponentDataFromEntity<MyData>
Thanks for the replying. Unfortunately, what I want to achieve is access entity from another archetype chunk. Seems like GetComponentDataFromEntity only able to get entity from the current archetype chunk.
No, you can do that!
1 Like
Incorrect. CDFE it’s lookup form all entities in current EM, it get’s data by type index from all types dictionary.
1 Like