Struct WeakObjectReference<TObject>
Weak reference to an object. This allows control over when an object is loaded and unloaded.
Namespace: Unity.Entities.Content
Assembly: solution.dll
Syntax
[Serializable]
public struct WeakObjectReference<TObject> where TObject : Object
Type Parameters
Name | Description |
---|---|
TObject | The type of UnityEngine.Object this reference points to. |
Constructors
Name | Description |
---|---|
WeakObjectReference(UntypedWeakReferenceId) | Weak reference to an object. |
WeakObjectReference(TObject) |
Properties
Name | Description |
---|---|
IsReferenceValid | Returns true if the reference has a valid id. In the editor, additional checks for the correct GenerationType and the existence of the referenced asset are performed. |
LoadingStatus | Get the loading status of the referenced object. |
Result | The value of the referenced object. This returns a valid object if IsLoaded is true. |
Methods
Name | Description |
---|---|
Equals(WeakObjectReference<TObject>) | Indicates whether the current object is equal to another object of the same type. |
GetHashCode() | Gets the hash code of this reference. |
LoadAsync() | Directs the object to begin loading. This will increase the reference count for each call to the same id. Release must be called for each Load call to properly release resources. |
Release() | Releases the object. This will decrement the reference count of this object. When an objects reference count reaches 0, the archive file is released. The archive file is only unloaded when its reference count reaches zero, which will then release the archive it was loaded from. Archives will be unmounted when their reference count reaches 0. |
ToString() | String conversion override. |
WaitForCompletion(int) | Wait for object load in main thread. This will force synchronous loading and may cause performance issues. |