Method CreateNativeArray
CreateNativeArray<T, U>(int, ref U, NativeArrayOptions)
Create a NativeArray, using a provided allocator that implements IAllocator.
Declaration
public static NativeArray<T> CreateNativeArray<T, U>(int length, ref U allocator, NativeArrayOptions options = NativeArrayOptions.ClearMemory) where T : unmanaged where U : unmanaged, AllocatorManager.IAllocator
Parameters
| Type | Name | Description |
|---|---|---|
| int | length | The number of elements to allocate. |
| U | allocator | The allocator to use. |
| NativeArrayOptions | options | Options for allocation, such as whether to clear the memory. |
Returns
| Type | Description |
|---|---|
| NativeArray<T> | Returns the NativeArray that was created. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the elements. |
| U | The type of allocator. |
CreateNativeArray<T>(int, AllocatorHandle, NativeArrayOptions)
Create a NativeArray, using a provided AllocatorHandle.
Declaration
public static NativeArray<T> CreateNativeArray<T>(int length, AllocatorManager.AllocatorHandle allocator, NativeArrayOptions options = NativeArrayOptions.ClearMemory) where T : unmanaged
Parameters
| Type | Name | Description |
|---|---|---|
| int | length | The number of elements to allocate. |
| AllocatorManager.AllocatorHandle | allocator | The AllocatorHandle to use. |
| NativeArrayOptions | options | Options for allocation, such as whether to clear the memory. |
Returns
| Type | Description |
|---|---|
| NativeArray<T> | Returns the NativeArray that was created. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the elements. |
CreateNativeArray<T>(NativeArray<T>, AllocatorHandle)
Create a NativeArray from another NativeArray, using a provided AllocatorHandle.
Declaration
public static NativeArray<T> CreateNativeArray<T>(NativeArray<T> array, AllocatorManager.AllocatorHandle allocator) where T : unmanaged
Parameters
| Type | Name | Description |
|---|---|---|
| NativeArray<T> | array | The NativeArray to make a copy of. |
| AllocatorManager.AllocatorHandle | allocator | The AllocatorHandle to use. |
Returns
| Type | Description |
|---|---|
| NativeArray<T> | Returns the NativeArray that was created. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the elements. |
CreateNativeArray<T>(T[], AllocatorHandle)
Create a NativeArray from a managed array, using a provided AllocatorHandle.
Declaration
[ExcludeFromBurstCompatTesting("Managed array")]
public static NativeArray<T> CreateNativeArray<T>(T[] array, AllocatorManager.AllocatorHandle allocator) where T : unmanaged
Parameters
| Type | Name | Description |
|---|---|---|
| T[] | array | The managed array to make a copy of. |
| AllocatorManager.AllocatorHandle | allocator | The AllocatorHandle to use. |
Returns
| Type | Description |
|---|---|
| NativeArray<T> | Returns the NativeArray that was created. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the elements. |
CreateNativeArray<T, U>(T[], ref U)
Create a NativeArray from a managed array, using a provided Allocator.
Declaration
[ExcludeFromBurstCompatTesting("Managed array")]
public static NativeArray<T> CreateNativeArray<T, U>(T[] array, ref U allocator) where T : unmanaged where U : unmanaged, AllocatorManager.IAllocator
Parameters
| Type | Name | Description |
|---|---|---|
| T[] | array | The managed array to make a copy of. |
| U | allocator | The Allocator to use. |
Returns
| Type | Description |
|---|---|
| NativeArray<T> | Returns the NativeArray that was created. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the elements. |
| U | The type of allocator. |