PoolableReference(T) Class

Audio Toolkit

Collapse image Expand Image Copy image CopyHover image
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).

Namespace: (Default Namespace)
Assembly: AudioToolkit (in AudioToolkit.dll) Version: 8.0.0.0 (8.0.0.0)

Syntax

C#
public class PoolableReference<T>
where T : Component

Type Parameters

T
A UnityEngine.Component

Examples

Instead of a normal reference to a script component on a poolable object use
 Copy imageCopy
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();
}

Inheritance Hierarchy

System..::..Object
  (Default Namespace)..::..PoolableReference<(Of <(<'T>)>)>

See Also