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

            m_Data = UnsafeArrayData.Create(UnsafeCollectionUtility.SizeOf <T>(), length);
        }
示例#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);
        }
示例#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;
        }
示例#4
0
 public void Dispose()
 {
     UnsafeArrayData.Destroy(m_Data);
     m_Data = null;
 }