public NavMeshQuery(NavMeshWorld world, Allocator allocator, int pathNodePoolSize = 0) { if (!world.IsValid()) { throw new ArgumentNullException("world", "Invalid world"); } if (pathNodePoolSize < 0 || pathNodePoolSize > ushort.MaxValue) { throw new ArgumentException($"The path node pool size ({pathNodePoolSize}) must be greater than or equal to 0 and less than {ushort.MaxValue + 1}."); } m_NavMeshQuery = Create(world, pathNodePoolSize); UnsafeUtility.LeakRecord(m_NavMeshQuery, LeakCategory.NavMeshQuery, 0); AtomicSafetyHandle.CreateHandle(out m_Safety, allocator); AddQuerySafety(m_NavMeshQuery, m_Safety); }
static void Allocate(int length, Allocator allocator, out NativeArray <T> array) { long totalSize = UnsafeUtility.SizeOf <T>() * (long)length; CheckAllocateArguments(length, allocator); array = default(NativeArray <T>); IsUnmanagedAndThrow(); array.m_Buffer = UnsafeUtility.MallocTracked(totalSize, UnsafeUtility.AlignOf <T>(), allocator, 0); array.m_Length = length; array.m_AllocatorLabel = allocator; array.m_MinIndex = 0; array.m_MaxIndex = length - 1; AtomicSafetyHandle.CreateHandle(out array.m_Safety, allocator); InitStaticSafetyId(ref array.m_Safety); InitNestedNativeContainer(array.m_Safety); }
public static void Allocate(int capacity, int desiredJobCount, out TransformAccessArray array) { array.m_TransformArray = Create(capacity, desiredJobCount); AtomicSafetyHandle.CreateHandle(out array.m_Safety, Allocator.Persistent); }