public NativeArrayFullSOA(int length, Allocator label, int stackDepth) { #if ENABLE_UNITY_COLLECTIONS_CHECKS if (!UnsafeUtility.IsBlittable <T>()) { throw new ArgumentException($"{typeof(T)} is not blittable"); } #endif if (!ms_CachedLayout.IsCreated) { ms_CachedLayout = new StructLayoutData4(typeof(T)); } m_Base = (byte *)UnsafeUtility.Malloc(4 * length * ms_CachedLayout.FieldCount, StructLayoutData4.ChunkSizeBytes, label); m_Length = length; m_Allocator = label; #if ENABLE_UNITY_COLLECTIONS_CHECKS #if UNITY_2018_3_OR_NEWER DisposeSentinel.Create(out m_Safety, out m_DisposeSentinel, stackDepth, label); #else DisposeSentinel.Create(out m_Safety, out m_DisposeSentinel, stackDepth); #endif #endif }
public NativeArrayFullSOA(int length, Allocator label, int stackDepth) { CollectionHelper.CheckIsUnmanaged <T>(); if (!ms_CachedLayout.IsCreated) { ms_CachedLayout = new StructLayoutData4(typeof(T)); } m_Base = (byte *)UnsafeUtility.Malloc(4 * length * ms_CachedLayout.FieldCount, StructLayoutData4.ChunkSizeBytes, label); m_Length = length; m_Allocator = label; #if ENABLE_UNITY_COLLECTIONS_CHECKS DisposeSentinel.Create(out m_Safety, out m_DisposeSentinel, stackDepth, label); #endif }
public NativeArraySOA(int length, Allocator label, int stackDepth) { #if ENABLE_UNITY_COLLECTIONS_CHECKS if (!UnsafeUtility.IsBlittable <T>()) { throw new ArgumentException($"{typeof(T)} is not blittable"); } #endif if (!ms_CachedLayout.IsCreated) { ms_CachedLayout = new StructLayoutData4(typeof(T)); } m_Base = (byte *)UnsafeUtility.Malloc(StructLayoutData4.ChunkSizeBytes * ms_CachedLayout.ChunksNeeded(length), StructLayoutData4.ChunkSizeBytes, Allocator.Temp); m_Length = length; m_Allocator = label; #if ENABLE_UNITY_COLLECTIONS_CHECKS DisposeSentinel.Create(out m_Safety, out m_DisposeSentinel, stackDepth); #endif }