Version: Unity 7.0 Alpha (7000.0)
LanguageEnglish
  • C#

UnityObjectRef<T0>

struct in Unity.Entities

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

A utility structure that stores a reference to a UnityEngine.Object for Entities, so unmanaged components can hold one.

Stores the Object's EntityId, and subscenes serialize the asset references it holds. This is the recommended way to store references to Unity assets in Entities because it remains unmanaged.

Serialization is supported on IComponentData, ISharedComponentData and IBufferElementData.

As when a MonoBehaviour references an asset, asset garbage collection (such as Resources.UnloadUnusedAssets) doesn't unload a referenced asset.

Properties

Property Description
EntityIdThe EntityId of the referenced object, or EntityId.None if it references nothing.
ValueThe Object this UnityObjectRef references.

Public Methods

Method Description
EqualsChecks if this reference and another reference are equal.
IsValidReturns true if the referenced Object still exists.

Static Methods

Method Description
FromEntityIdCreates a reference to the object with the given EntityId.

Operators

Operator Description
boolChecks whether the reference points to a valid object.
operator !=Returns true if two UnityObjectRef values are not equal.
operator ==Returns true if two UnityObjectRef values are equal.
TImplicitly converts a UnityObjectRef to the UnityEngine.Object it references.
UnityObjectRef<T>Implicitly converts a UnityEngine.Object to a UnityObjectRef.