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.