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.
| Property | Description |
|---|---|
| EntityId | The EntityId of the referenced object, or EntityId.None if it references nothing. |
| Value | The Object this UnityObjectRef references. |
| Method | Description |
|---|---|
| Equals | Checks if this reference and another reference are equal. |
| IsValid | Returns true if the referenced Object still exists. |
| Method | Description |
|---|---|
| FromEntityId | Creates a reference to the object with the given EntityId. |
| Operator | Description |
|---|---|
| bool | Checks 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. |
| T | Implicitly converts a UnityObjectRef to the UnityEngine.Object it references. |
| UnityObjectRef<T> | Implicitly converts a UnityEngine.Object to a UnityObjectRef. |