Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


Release(T)

Returns the instance back to the pool. If the pool has reached maximum size, the returned instance is destroyed.
Read time 1 minuteLast updated 6 days ago

Definition

public void Release(T element)

Parameters

element

T
The instance to return to the pool.

Remarks

Calls to
Release
invoke the delegate passed to the constructor as the
actionOnRelease
parameter.
Any instance returned to a pool that's already full is destroyed and the
actionOnDestroy
delegate is invoked if one was provided to the constructor. The pool is considered full when the number of objects it contains is equal to the pool's maximum size, as defined by the value of the
maxSize
parameter passed to the constructor.
If collection checks are enabled, then calling
Release
on an instance that is already in the pool throws an exception. Collection checks are enabled by passing
true
as the value of the
collectionCheck
argument to the constructor. Collection checks only run in the Editor and not in a Player build.
Additional Resources: ctor.