docs.unity.cn
    Show / Hide Table of Contents

    Method AllocateNativeArray

    AllocateNativeArray<T>(Int32)

    Allocate a NativeArray of type T from memory that's guaranteed to remain valid until Rewind() is called on the Scratchpad.

    Declaration
    [GenerateTestsForBurstCompatibility(GenericTypeArguments = new Type[]{typeof(int)})]
    public NativeArray<T> AllocateNativeArray<T>(int length)
        where T : struct
    Parameters
    Type Name Description
    Int32 length

    The number of items in the NativeArray.

    Returns
    Type Description
    NativeArray<T>

    Returns the NativeArray.

    Type Parameters
    Name Description
    T

    The NativeArray.

    Remarks

    This memory isn't shared between threads and you don't need to Dispose the NativeArray so it's allocated. You can't Dispose the memory to free it: it's automatically freed when Rewind() is called.

    Back to top Copyright © 2023 Unity Technologies — Terms of use
    Generated by DocFX
    on Thursday, August 10, 2023