LayerProcGen v0.1.0
Layer-based infinite procedural generation
|
Represents an object pool that poolable objects can be retrieved from and returned to. More...
Inherits IPool.
Inherited by ObjectPool< T >.
Public Member Functions | |
T | Get () |
Gets an existing object from the pool, or creates one if none are available. | |
void | Return (ref T obj) |
Returns the object to the pool and sets the reference to null. | |
Properties | |
int | CountActive [get] |
int | CountAll [get] |
int | CountInactive [get] |
Represents an object pool that poolable objects can be retrieved from and returned to.
Used by creating a long-lived pool instance of a given type and, when needed, calling Get
to retrieve an object from the pool and Return
to return it to the pool. The following classes implement the interface:
ObjectPool can be used to pool objects that implement the IPoolable interface and support an empty constructor. Unlike the other pool types, ObjectPool also has static GlobalGet
and GlobalReturn
functions that can be used without creating a pool instance.
ArrayPool can be used to pool arrays of a specific length specified in the pool constructor. Array2DPool and Array3DPool can be used for arrays of two and three dimensions.
ListPool can be used to pool Lists of a specific capacity specified in the pool constructor.
The background for these classes is that, as many Unity developers know, it's best to avoid generating "garbage" to be collected by the .Net garbage collector. A common way to avoid this is to pool and reuse resources rather than creating new ones every time one is needed.
T Get | ( | ) |
Gets an existing object from the pool, or creates one if none are available.
Implemented in ObjectPool< T >.
void Return | ( | ref T | obj | ) |
Returns the object to the pool and sets the reference to null.
Implemented in ObjectPool< T >.