public unsafe static void Copy(NativeArray <T> .ReadOnly src, int srcIndex, NativeArray <T> dst, int dstIndex, int length) { AtomicSafetyHandle.CheckReadAndThrow(src.m_Safety); AtomicSafetyHandle.CheckWriteAndThrow(dst.m_Safety); NativeArray <T> .CheckCopyArguments(src.Length, srcIndex, dst.Length, dstIndex, length); UnsafeUtility.MemCpy((void *)((byte *)dst.m_Buffer + dstIndex * UnsafeUtility.SizeOf <T>()), (void *)((byte *)src.m_Buffer + srcIndex * UnsafeUtility.SizeOf <T>()), (long)(length * UnsafeUtility.SizeOf <T>())); }
public unsafe static void Copy(NativeArray <T> .ReadOnly src, int srcIndex, T[] dst, int dstIndex, int length) { AtomicSafetyHandle.CheckReadAndThrow(src.m_Safety); bool flag = dst == null; if (flag) { throw new ArgumentNullException("dst"); } NativeArray <T> .CheckCopyArguments(src.Length, srcIndex, dst.Length, dstIndex, length); GCHandle gCHandle = GCHandle.Alloc(dst, GCHandleType.Pinned); IntPtr value = gCHandle.AddrOfPinnedObject(); UnsafeUtility.MemCpy((void *)((byte *)((void *)value) + dstIndex * UnsafeUtility.SizeOf <T>()), (void *)((byte *)src.m_Buffer + srcIndex * UnsafeUtility.SizeOf <T>()), (long)(length * UnsafeUtility.SizeOf <T>())); gCHandle.Free(); }