public void Execute(ArchetypeChunk chunk, int chunkIndex, int entityOffset) { var destinationPtr = (byte *)NativeArrayUnsafeUtility.GetUnsafePtr(Entities) + sizeof(Entity) * entityOffset; var chunkEntityArray = chunk.GetNativeArray(EntityType); var sourcePtr = (byte *)NativeArrayUnsafeUtility.GetUnsafeReadOnlyPtr(chunkEntityArray); var copySizeInBytes = sizeof(Entity) * chunk.Count; UnsafeUtility.MemCpy(destinationPtr, sourcePtr, copySizeInBytes); }
public unsafe void Execute(ArchetypeChunk chunk, int chunkIndex, int entityOffset) { var srcComponentData = chunk.GetNativeArray(ComponentType); var sourcePtr = (byte *)NativeArrayUnsafeUtility.GetUnsafeReadOnlyPtr(srcComponentData); var sizeOfComponentType = UnsafeUtility.SizeOf <T>(); var destinationPtr = (byte *)NativeArrayUnsafeUtility.GetUnsafePtr(ComponentData) + sizeOfComponentType * entityOffset; var copySizeInBytes = UnsafeUtility.SizeOf <T>() * chunk.Count; UnsafeUtility.MemCpy(destinationPtr, sourcePtr, copySizeInBytes); }