Beispiel #1
0
        public AiNativeArray(int length)
        {
            if (length <= 0)
            {
                throw new ArgumentException("Length must be > 0");
            }

            m_Data = UnsafeArrayData.Create(UnsafeCollectionUtility.SizeOf <T>(), length);
        }
Beispiel #2
0
        public static UnsafeArrayData *Create(int sizeOf, int length)
        {
            UnsafeArrayData *arrayData = (UnsafeArrayData *)Marshal.AllocHGlobal(UnsafeCollectionUtility.SizeOf <UnsafeArrayData>());

            var bytesToMalloc = sizeOf * length;

            arrayData->Ptr    = (void *)Marshal.AllocHGlobal(bytesToMalloc);
            arrayData->Length = length;

            return(arrayData);
        }
Beispiel #3
0
        public static void Destroy(UnsafeArrayData *listData)
        {
#if DEBUG || ENABLE_UNITY_COLLECTIONS_CHECKS
            if (listData == null)
            {
                throw new InvalidOperationException("UnsafeListData has yet to be created or has been destroyed!");
            }
#endif
            listData->Dispose();
            Marshal.FreeHGlobal((IntPtr)listData);
            listData = null;
        }
Beispiel #4
0
 public void Dispose()
 {
     UnsafeArrayData.Destroy(m_Data);
     m_Data = null;
 }