Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


NativeReference<T>

An unmanaged single value.
Read time 1 minuteLast updated 7 days ago

Definition

public struct NativeReference<T> : INativeDisposable, IDisposable, IEquatable<NativeReference<T>> where T : unmanaged

Remarks

The functional equivalent of an array of length 1. When you need just one value, NativeReference can be preferable to an array because it better conveys the intent.

Constructors

Constructor

Description

NativeReference`1(`0,Unity.Collections.AllocatorManager.AllocatorHandle)Initializes and returns an instance of NativeReference.
NativeReference`1(Unity.Collections.AllocatorManager.AllocatorHandle,Unity.Collections.NativeArrayOptions)Initializes and returns an instance of NativeReference.

Properties

Property

Description

IsCreatedWhether this reference has been allocated (and not yet deallocated).
ValueThe value stored in this reference.

Methods

Method

Description

AsReadOnlyReturns a read-only reference aliasing the value of this reference.
CopyFromCopy the value of another reference to this reference.
CopyToCopy the value of this reference to another reference.
DisposeReleases all resources (memory and safety handles).
EqualsReturns true if the value stored in this reference is equal to an object.
GetHashCodeReturns the hash code of this reference.

Static Methods

Method

Description

CopyCopies the value of a reference to another reference.

Operators

Operator

Description

operator ==Returns true if the values stored in two references are equal.
ReadOnlyReturns a read-only native reference that aliases the content of a native reference.
operator !=Returns true if the values stored in two references are unequal.

Structs

Struct

Description

NativeReference<T>.ReadOnlyA read-only alias for the value of a NativeReference. Does not have its own allocated storage.