Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


NativeArray

Creates a new NativeArray and allocates enough memory to fit the provided amount of elements.
Read time 2 minutesLast updated 5 days ago

Definition

NativeArray(int, Allocator, NativeArrayOptions)

Creates a new NativeArray and allocates enough memory to fit the provided amount of elements.
public NativeArray(int length, Allocator allocator, NativeArrayOptions options = NativeArrayOptions.ClearMemory)

Parameters

length

Number of elements to allocate.

allocator

The Allocator to use for the data.

The NativeArrayOptions to use for the data.

NativeArray(int, MemoryLabel, NativeArrayOptions)

Creates a new NativeArray and allocates enough memory to fit the provided number of elements, using the specified memory label.
public NativeArray(int length, MemoryLabel label, NativeArrayOptions options = NativeArrayOptions.ClearMemory)

Parameters

length

Number of elements to allocate.

The MemoryLabel to allocate under.

The NativeArrayOptions to use for the data.

NativeArray(`0[], Allocator)

Creates a NativeArray from an array of elements.
public NativeArray(T[] array, Allocator allocator)

Parameters

array

An array to copy the data from.

allocator

The Allocator to use for the data.

NativeArray(`0[], MemoryLabel)

Creates a NativeArray from an array of elements, using the specified memory label.
public NativeArray(T[] array, MemoryLabel label)

Parameters

array

An array to copy the data from.

The MemoryLabel to allocate under.

NativeArray(NativeArray<T>, Allocator)

Creates a NativeArray from an existing NativeArray.
public NativeArray(NativeArray<T> array, Allocator allocator)

Parameters

The NativeArray<T> to copy the data from.

allocator

The Allocator to use for the data.

NativeArray(NativeArray<T>, MemoryLabel)

Creates a NativeArray from an existing NativeArray, using the specified memory label.
public NativeArray(NativeArray<T> array, MemoryLabel label)

Parameters

The NativeArray<T> to copy the data from.

The MemoryLabel to allocate under.