Class ObjectPool<T>
Generic object pool.
Namespace: UnityEngine.Rendering
Syntax
public class ObjectPool<T>
where T : new()
Type Parameters
Name | Description |
---|---|
T | Type of the object pool. |
Constructors
ObjectPool(UnityAction<T>, UnityAction<T>, Boolean)
Constructor.
Declaration
public ObjectPool(UnityAction<T> actionOnGet, UnityAction<T> actionOnRelease, bool collectionCheck = true)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Events.UnityAction<T> | actionOnGet | Action on get. |
UnityEngine.Events.UnityAction<T> | actionOnRelease | Action on release. |
Boolean | collectionCheck | True if collection integrity should be checked. |
Properties
countActive
Number of active objects in the pool.
Declaration
public int countActive { get; }
Property Value
Type | Description |
---|---|
Int32 |
countAll
Number of objects in the pool.
Declaration
public int countAll { get; }
Property Value
Type | Description |
---|---|
Int32 |
countInactive
Number of inactive objects in the pool.
Declaration
public int countInactive { get; }
Property Value
Type | Description |
---|---|
Int32 |
Methods
Get()
Get an object from the pool.
Declaration
public T Get()
Returns
Type | Description |
---|---|
T | A new object from the pool. |
Get(out T)
Get et new PooledObject.
Declaration
public ObjectPool<T>.PooledObject Get(out T v)
Parameters
Type | Name | Description |
---|---|---|
T | v | Output new typed object. |
Returns
Type | Description |
---|---|
ObjectPool.PooledObject<> | New PooledObject |
Release(T)
Release an object to the pool.
Declaration
public void Release(T element)
Parameters
Type | Name | Description |
---|---|---|
T | element | Object to release. |