Weird bug with getting dynamic buffers

Hello all,

This returns an error

DynamicBuffer<SailDisplayPoint> sailPointsBuffer = EntityManager.AddBuffer<SailDisplayPoint>(headEntity);
DynamicBuffer<SailDisplayTri> sailTrisBuffer = EntityManager.AddBuffer<SailDisplayTri>(headEntity);

for(int i = 0, l = entities.Length; i < l; i++)
   sailPointsBuffer.Add(new SailDisplayPoint() { Entity = entities[i] });

“InvalidOperationException: The NativeArray has been deallocated, it is not allowed to access it” on the last line BUT

DynamicBuffer<SailDisplayPoint> sailPointsBuffer = EntityManager.AddBuffer<SailDisplayPoint>(headEntity);
//DynamicBuffer<SailDisplayTri> sailTrisBuffer = EntityManager.AddBuffer<SailDisplayTri>(headEntity);

for(int i = 0, l = entities.Length; i < l; i++)
   sailPointsBuffer.Add(new SailDisplayPoint() { Entity = entities[i] });

I have not referenced sailTrisBuffer at all and can’t see what I am doing wrong. Can there only be one Dynamic Buffer per entity?

Any structural change call to EntityManager invalidates arrays.

Simply need to call getbuffer after you add the second buffer instead.

Ah makes sense! Thanks as always for the help.