DynamicBuffer.RemoveAtSwapBack copy only byte size data.

        public void RemoveAtSwapBack(int index)
        {
            CheckWriteAccess();
            CheckBounds(index);

            ref var l = ref m_Buffer->Length;
            l -= 1;
            int newLength = l;
            if (index != newLength)
            {
                int elemSize = UnsafeUtility.SizeOf<T>();
                byte* basePtr = BufferHeader.GetElementPointer(m_Buffer);
                *(basePtr + index * elemSize) = *(basePtr + newLength * elemSize);
            }
        }

where basePtr is only a byte pointer.
author forget to cast to T* like
*(T*)(basePtr + index * elemSize) = *(T*)(basePtr + newLength * elemSize)
It take me quit a while to figure out what’s wrong.

4 Likes

working temp walk-around.
internal access to Unity.Entities required

6387015–711798–DynamicBufferWalkAround.cs (4.72 KB)

Thanks for reporting this; it’s been fixed yesterday when I also found it :slight_smile: will likely take some time until it is available in a release.

2 Likes