ClockStone Audio Toolkit for Unity - Documentation
PoolableReferenceT Class |
Auxiliary class to overcome the problem of references to pooled objects that should become null when
objects are moved back to the pool after calling Destroy(GameObject).
Inheritance Hierarchy
Namespace: (Default Namespace)
Assembly: AudioToolkit (in AudioToolkit.dll) Version: 8.2.0.0 (8.2.0.0)
Syntax
C#
public class PoolableReference<T> where T : Component
Type Parameters
- T
- A UnityEngine.Component
The PoolableReferenceT type exposes the following members.
Constructors
Name | Description | |
---|---|---|
PoolableReferenceT |
Initializes a new instance of the PoolableReferenceT class with a null reference.
| |
PoolableReferenceT(T) |
Initializes a new instance of the PoolableReferenceT class with the specified reference.
| |
PoolableReferenceT(PoolableReferenceT) |
Initializes a new instance of the PoolableReferenceT class from
a given PoolableReferenceT.
|
Methods
Name | Description | |
---|---|---|
Get |
Gets the reference to the script component, or null if the object was
already destroyed or moved to the pool.
| |
Reset |
Resets the reference to null.
| |
Set(T) | ||
Set(T, Boolean) |
Sets the reference to a poolable object with the specified component.
|
Examples
Instead of a normal reference to a script component on a poolable object use
MyScriptComponent scriptComponent = PoolableObjectController.Instantiate( prefab ).GetComponent<MyScriptComponent>(); var myReference = new PoolableReference<MyScriptComponent>( scriptComponent ); if( myReference.Get() != null ) // will check if poolable instance still belongs to the original object { myReference.Get().MyComponentFunction(); }
See Also