Hi all,
Wondering if there is a better way to do this.
I have a vehicle entity which has three Dynamic Buffers. I need multiple components from the entities in those dynamic buffers.
I simplified the code below to only show one example of the pattern, but in my code it ends up being 24 calls to GetComponentData(), and 3 calls to GetBuffer(). Which may not be a big deal and may be the correct approach I am just not sure.
Entities.ForEach((Entity entity, ref Vehicle vehicle, ref Chasis chasis, ref Rotation rotation) =>
{
DynamicBuffer<SuspensionBufferElement> suspensions = EntityManager.GetBuffer<SuspensionBufferElement>(entity);
NativeArray<Suspension> suspensionComponents = new NativeArray<Suspension>(suspensions.Length,Allocator.Temp);
for (int i = 0; i < suspensions.Length; i++)
{
suspensionComponents[i] = EntityManager.GetComponentData<Suspension>(suspensions[i]);
}
Thanks,