Ejemplo n.º 1
0
 public static ref T GetRef <T>(this Unity.Collections.NativeArray <T> array, int index) where T : struct
 {
     CheckArray(index, array.Length);
     unsafe {
         var ptr = array.GetUnsafePtr();
         #if UNITY_2020_1_OR_NEWER
         return(ref UnsafeUtility.ArrayElementAsRef <T>(ptr, index));
         #else
         throw new Exception("UnsafeUtility.ArrayElementAsRef");
         #endif
     }
 }
Ejemplo n.º 2
0
 public static ref T GetRef <T>(this Unity.Collections.NativeArray <T> array, int index) where T : struct
 {
     if (index < 0 || index >= array.Length)
     {
         throw new ArgumentOutOfRangeException(nameof(index));
     }
     unsafe {
         var ptr = array.GetUnsafePtr();
         #if UNITY_2020_1_OR_NEWER
         return(ref UnsafeUtility.ArrayElementAsRef <T>(ptr, index));
         #else
         throw new Exception("UnsafeUtility.ArrayElementAsRef");
         #endif
     }
 }
Ejemplo n.º 3
0
 public static unsafe void Clear <T>(Unity.Collections.NativeArray <T> arr, int index, int length) where T : struct
 {
     Unity.Collections.LowLevel.Unsafe.UnsafeUtility.MemClear((void *)((System.IntPtr)arr.GetUnsafePtr() + (int)((ulong)UnsafeUtility.SizeOf <T>() * (ulong)index)), (long)((ulong)UnsafeUtility.SizeOf <T>() * (ulong)length));
 }
Ejemplo n.º 4
0
 public static unsafe void Clear <T>(Unity.Collections.NativeArray <T> arr) where T : struct
 {
     Unity.Collections.LowLevel.Unsafe.UnsafeUtility.MemClear(arr.GetUnsafePtr(), UnsafeUtility.SizeOf <T>() * arr.Length);
 }