Struct NativeReference<T> | Collections | 0.11.0-preview.17
docs.unity3d.com
    Show / Hide Table of Contents

    Struct NativeReference<T>

    An unmanaged, reference container.

    Namespace: Unity.Collections
    Syntax
    [NativeContainer]
    [NativeContainerSupportsDeallocateOnJobCompletion]
    public struct NativeReference<T> : IDisposable, IEquatable<NativeReference<T>> where T : struct
    Type Parameters
    Name Description
    T

    The type of the reference in the container.

    Constructors

    NativeReference(Allocator, NativeArrayOptions)

    Constructs a new reference container using the specified type of memory allocation.

    Declaration
    public NativeReference(Allocator allocator, NativeArrayOptions options = NativeArrayOptions.ClearMemory)
    Parameters
    Type Name Description
    Allocator allocator

    A member of the Unity.Collections.Allocator enumeration.

    NativeArrayOptions options

    A member of the Unity.Collections.NativeArrayOptions enumeration.

    Properties

    IsCreated

    Determine whether or not this container is created.

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

    Value

    The value of this container.

    Declaration
    public T Value { get; set; }
    Property Value
    Type Description
    T

    Methods

    AsReadOnly()

    Retrieve this container as read-only.

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

    A read-only reference container.

    Copy(NativeReference<T>, NativeReference<T>)

    Copy source container to destination container.

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

    The destination reference.

    NativeReference<T> src

    The source reference.

    CopyFrom(NativeReference<T>)

    Copy this container from another container.

    Declaration
    public void CopyFrom(NativeReference<T> reference)
    Parameters
    Type Name Description
    NativeReference<T> reference

    The container to copy from.

    CopyTo(NativeReference<T>)

    Copy this container to another container.

    Declaration
    public void CopyTo(NativeReference<T> reference)
    Parameters
    Type Name Description
    NativeReference<T> reference

    The container to copy to.

    Dispose()

    Disposes of this container and deallocates its memory immediately.

    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

    The job handle or handles for any scheduled jobs that use this container.

    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)

    Determine whether this object is equal to another object of the same type.

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    Object obj

    An object to compare with this object.

    Returns
    Type Description
    Boolean

    true if this object is equal to the obj parameter, otherwise false.

    Overrides
    ValueType.Equals(Object)

    Equals(NativeReference<T>)

    Determine whether this container is equal to another container.

    Declaration
    public bool Equals(NativeReference<T> other)
    Parameters
    Type Name Description
    NativeReference<T> other

    A container to compare with this container.

    Returns
    Type Description
    Boolean

    true if this container is equal to the other parameter, otherwise false.

    GetHashCode()

    Returns the hash code for this container.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    Int32

    A 32-bit signed integer hash code.

    Overrides
    ValueType.GetHashCode()

    Operators

    Equality(NativeReference<T>, NativeReference<T>)

    Determine whether a container is equal to another container.

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

    Left-hand side container.

    NativeReference<T> right

    Right-hand side container.

    Returns
    Type Description
    Boolean

    true if left parameter is equal to the right parameter, otherwise false.

    Inequality(NativeReference<T>, NativeReference<T>)

    Determine whether a container is not equal to another container.

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

    Left-hand side container.

    NativeReference<T> right

    Right-hand side container.

    Returns
    Type Description
    Boolean

    true if left parameter is not equal to the right parameter, otherwise false.

    Extension Methods

    NativeReferenceUnsafeUtility.GetUnsafePtr<T>(NativeReference<T>)
    NativeReferenceUnsafeUtility.GetUnsafeReadOnlyPtr<T>(NativeReference<T>)
    In This Article
    • Constructors
      • NativeReference(Allocator, NativeArrayOptions)
    • Properties
      • IsCreated
      • Value
    • Methods
      • AsReadOnly()
      • Copy(NativeReference<T>, NativeReference<T>)
      • CopyFrom(NativeReference<T>)
      • CopyTo(NativeReference<T>)
      • Dispose()
      • Dispose(JobHandle)
      • Equals(Object)
      • Equals(NativeReference<T>)
      • GetHashCode()
    • Operators
      • Equality(NativeReference<T>, NativeReference<T>)
      • Inequality(NativeReference<T>, NativeReference<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