Class ObjectPool<T>
Generic object pool.
Inherited Members
Namespace: UnityEngine.Rendering
Assembly: Unity.RenderPipelines.Core.Runtime.dll
Syntax
public class ObjectPool<T> where T : new()
Type Parameters
Name | Description |
---|---|
T | Type of the object pool. |
Constructors
ObjectPool(UnityAction<T>, UnityAction<T>, bool)
Constructor.
Declaration
public ObjectPool(UnityAction<T> actionOnGet, UnityAction<T> actionOnRelease, bool collectionCheck = true)
Parameters
Type | Name | Description |
---|---|---|
UnityAction<T> | actionOnGet | Action on get. |
UnityAction<T> | actionOnRelease | Action on release. |
bool | 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 |
---|---|
int |
countAll
Number of objects in the pool.
Declaration
public int countAll { get; }
Property Value
Type | Description |
---|---|
int |
countInactive
Number of inactive objects in the pool.
Declaration
public int countInactive { get; }
Property Value
Type | Description |
---|---|
int |
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<T>.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. |