Struct NativeArray<T> | DOTS Runtime | 0.28.0-preview.40
docs.unity3d.com
    Show / Hide Table of Contents

    Struct NativeArray<T>

    Namespace: Unity.Collections
    Syntax
    public struct NativeArray<T> : IDisposable, IEnumerable<T>, IEnumerable, IEquatable<NativeArray<T>> where T : struct
    Type Parameters
    Name Description
    T

    Constructors

    NativeArray(T[], Allocator)

    Declaration
    public NativeArray(T[] array, Allocator allocator)
    Parameters
    Type Name Description
    T[] array
    Allocator allocator

    NativeArray(Int32, Allocator, NativeArrayOptions)

    Declaration
    public NativeArray(int length, Allocator allocator, NativeArrayOptions options = NativeArrayOptions.ClearMemory)
    Parameters
    Type Name Description
    Int32 length
    Allocator allocator
    NativeArrayOptions options

    NativeArray(NativeArray<T>, Allocator)

    Declaration
    public NativeArray(NativeArray<T> array, Allocator allocator)
    Parameters
    Type Name Description
    NativeArray<T> array
    Allocator allocator

    Properties

    IsCreated

    Declaration
    public bool IsCreated { get; }
    Property Value
    Type Description
    Boolean

    Item[Int32]

    Declaration
    public T this[int index] { get; set; }
    Parameters
    Type Name Description
    Int32 index
    Property Value
    Type Description
    T

    Length

    Declaration
    public int Length { get; }
    Property Value
    Type Description
    Int32

    Methods

    AsReadOnly()

    Declaration
    public NativeArray<T>.ReadOnly AsReadOnly()
    Returns
    Type Description
    NativeArray.ReadOnly<>

    Copy(T[], Int32, NativeArray<T>, Int32, Int32)

    Declaration
    public static void Copy(T[] src, int srcIndex, NativeArray<T> dst, int dstIndex, int length)
    Parameters
    Type Name Description
    T[] src
    Int32 srcIndex
    NativeArray<T> dst
    Int32 dstIndex
    Int32 length

    Copy(T[], NativeArray<T>)

    Declaration
    public static void Copy(T[] src, NativeArray<T> dst)
    Parameters
    Type Name Description
    T[] src
    NativeArray<T> dst

    Copy(T[], NativeArray<T>, Int32)

    Declaration
    public static void Copy(T[] src, NativeArray<T> dst, int length)
    Parameters
    Type Name Description
    T[] src
    NativeArray<T> dst
    Int32 length

    Copy(NativeArray<T>, T[])

    Declaration
    public static void Copy(NativeArray<T> src, T[] dst)
    Parameters
    Type Name Description
    NativeArray<T> src
    T[] dst

    Copy(NativeArray<T>, T[], Int32)

    Declaration
    public static void Copy(NativeArray<T> src, T[] dst, int length)
    Parameters
    Type Name Description
    NativeArray<T> src
    T[] dst
    Int32 length

    Copy(NativeArray<T>, Int32, T[], Int32, Int32)

    Declaration
    public static void Copy(NativeArray<T> src, int srcIndex, T[] dst, int dstIndex, int length)
    Parameters
    Type Name Description
    NativeArray<T> src
    Int32 srcIndex
    T[] dst
    Int32 dstIndex
    Int32 length

    Copy(NativeArray<T>, Int32, NativeArray<T>, Int32, Int32)

    Declaration
    public static void Copy(NativeArray<T> src, int srcIndex, NativeArray<T> dst, int dstIndex, int length)
    Parameters
    Type Name Description
    NativeArray<T> src
    Int32 srcIndex
    NativeArray<T> dst
    Int32 dstIndex
    Int32 length

    Copy(NativeArray<T>, NativeArray<T>)

    Declaration
    public static void Copy(NativeArray<T> src, NativeArray<T> dst)
    Parameters
    Type Name Description
    NativeArray<T> src
    NativeArray<T> dst

    Copy(NativeArray<T>, NativeArray<T>, Int32)

    Declaration
    public static void Copy(NativeArray<T> src, NativeArray<T> dst, int length)
    Parameters
    Type Name Description
    NativeArray<T> src
    NativeArray<T> dst
    Int32 length

    CopyFrom(T[])

    Declaration
    public void CopyFrom(T[] array)
    Parameters
    Type Name Description
    T[] array

    CopyFrom(NativeArray<T>)

    Declaration
    public void CopyFrom(NativeArray<T> array)
    Parameters
    Type Name Description
    NativeArray<T> array

    CopyTo(T[])

    Declaration
    public void CopyTo(T[] array)
    Parameters
    Type Name Description
    T[] array

    CopyTo(NativeArray<T>)

    Declaration
    public void CopyTo(NativeArray<T> array)
    Parameters
    Type Name Description
    NativeArray<T> array

    Dispose()

    Declaration
    public void Dispose()

    Dispose(JobHandle)

    Safely disposes of this container and deallocates its memory when the jobs that use it have completed.

    Declaration
    public JobHandle Dispose(JobHandle inputDeps)
    Parameters
    Type Name Description
    JobHandle inputDeps
    Returns
    Type Description
    JobHandle

    A new job handle containing the prior handles as well as the handle for the job that deletes the container.

    Remarks

    You can call this function dispose of the container immediately after scheduling the job. Pass the JobHandle returned by the Job.Schedule method using the jobHandle parameter so the job scheduler can dispose the container after all jobs using it have run.

    Equals(Object)

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    Object obj
    Returns
    Type Description
    Boolean
    Overrides
    ValueType.Equals(Object)

    Equals(NativeArray<T>)

    Declaration
    public bool Equals(NativeArray<T> other)
    Parameters
    Type Name Description
    NativeArray<T> other
    Returns
    Type Description
    Boolean

    GetEnumerator()

    Declaration
    public NativeArray<T>.Enumerator GetEnumerator()
    Returns
    Type Description
    NativeArray.Enumerator<>

    GetHashCode()

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    Int32
    Overrides
    ValueType.GetHashCode()

    GetSubArray(Int32, Int32)

    Declaration
    public NativeArray<T> GetSubArray(int start, int length)
    Parameters
    Type Name Description
    Int32 start
    Int32 length
    Returns
    Type Description
    NativeArray<T>

    Reinterpret<U>()

    Declaration
    public NativeArray<U> Reinterpret<U>()
        where U : struct
    Returns
    Type Description
    NativeArray<U>
    Type Parameters
    Name Description
    U

    Reinterpret<U>(Int32)

    Declaration
    public NativeArray<U> Reinterpret<U>(int expectedTypeSize)
        where U : struct
    Parameters
    Type Name Description
    Int32 expectedTypeSize
    Returns
    Type Description
    NativeArray<U>
    Type Parameters
    Name Description
    U

    ReinterpretLoad<U>(Int32)

    Declaration
    public U ReinterpretLoad<U>(int sourceIndex)
        where U : struct
    Parameters
    Type Name Description
    Int32 sourceIndex
    Returns
    Type Description
    U
    Type Parameters
    Name Description
    U

    ReinterpretStore<U>(Int32, U)

    Declaration
    public void ReinterpretStore<U>(int destIndex, U data)
        where U : struct
    Parameters
    Type Name Description
    Int32 destIndex
    U data
    Type Parameters
    Name Description
    U

    ToArray()

    Declaration
    public T[] ToArray()
    Returns
    Type Description
    T[]

    Operators

    Equality(NativeArray<T>, NativeArray<T>)

    Declaration
    public static bool operator ==(NativeArray<T> left, NativeArray<T> right)
    Parameters
    Type Name Description
    NativeArray<T> left
    NativeArray<T> right
    Returns
    Type Description
    Boolean

    Inequality(NativeArray<T>, NativeArray<T>)

    Declaration
    public static bool operator !=(NativeArray<T> left, NativeArray<T> right)
    Parameters
    Type Name Description
    NativeArray<T> left
    NativeArray<T> right
    Returns
    Type Description
    Boolean

    Extension Methods

    NativeSliceExtensions.Slice<T>(NativeArray<T>)
    NativeSliceExtensions.Slice<T>(NativeArray<T>, Int32)
    NativeSliceExtensions.Slice<T>(NativeArray<T>, Int32, Int32)
    NativeArrayUnsafeUtility.GetUnsafePtr<T>(NativeArray<T>)
    NativeArrayUnsafeUtility.GetUnsafeReadOnlyPtr<T>(NativeArray<T>)
    In This Article
    • Constructors
      • NativeArray(T[], Allocator)
      • NativeArray(Int32, Allocator, NativeArrayOptions)
      • NativeArray(NativeArray<T>, Allocator)
    • Properties
      • IsCreated
      • Item[Int32]
      • Length
    • Methods
      • AsReadOnly()
      • Copy(T[], Int32, NativeArray<T>, Int32, Int32)
      • Copy(T[], NativeArray<T>)
      • Copy(T[], NativeArray<T>, Int32)
      • Copy(NativeArray<T>, T[])
      • Copy(NativeArray<T>, T[], Int32)
      • Copy(NativeArray<T>, Int32, T[], Int32, Int32)
      • Copy(NativeArray<T>, Int32, NativeArray<T>, Int32, Int32)
      • Copy(NativeArray<T>, NativeArray<T>)
      • Copy(NativeArray<T>, NativeArray<T>, Int32)
      • CopyFrom(T[])
      • CopyFrom(NativeArray<T>)
      • CopyTo(T[])
      • CopyTo(NativeArray<T>)
      • Dispose()
      • Dispose(JobHandle)
      • Equals(Object)
      • Equals(NativeArray<T>)
      • GetEnumerator()
      • GetHashCode()
      • GetSubArray(Int32, Int32)
      • Reinterpret<U>()
      • Reinterpret<U>(Int32)
      • ReinterpretLoad<U>(Int32)
      • ReinterpretStore<U>(Int32, U)
      • ToArray()
    • Operators
      • Equality(NativeArray<T>, NativeArray<T>)
      • Inequality(NativeArray<T>, NativeArray<T>)
    • Extension Methods
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023