private static void Copy(NativeArray2D <T> src, NativeArray2D <T> dest)
        {
            src.RequireReadAccess();
            dest.RequireWriteAccess();

            if (src.Length0 != dest.Length0 || src.Length1 != dest.Length1)
            {
                throw new ArgumentException("NativeArray2Ds must have the same size.");
            }

            UnsafeUtility.MemCpy(dest.GetUnsafePtr(), src.GetUnsafePtr(), src.Length0 * src.Length1 * UnsafeUtility.SizeOf <T>());
        }
Exemple #2
0
        private static void Copy(T[] src, NativeArray2D <T> dest)
        {
            dest.RequireWriteAccess();

            if (src.Length != dest.Length)
                throw new ArgumentException("Arrays must have the same size.");

            fixed(void *srcPtr = &src[0])
            {
                UnsafeUtility.MemCpy(dest.GetUnsafePtr(), srcPtr, dest.Length * sizeof(T));
            }
        }