![]() |
Infohazard.Core 1.4.1
Infohazard Core Utility Library
|
Provides a simple pool with an interface similar to the official Unity pool added in 2021. More...
Public Member Functions | |
Pool (Func< T > createFunc, Action< T > getAction=null, Action< T > releaseAction=null, Action< T > destroyAction=null, int maxCount=0) | |
Create a new ObjectPool. More... | |
T | Get () |
Retrieve an item from the pool, creating a new one if necessary. More... | |
void | Release (T item) |
Return an object to the pool, destroying it if over max count. More... | |
void | Clear () |
Destroy all objects in the pool. More... | |
void | Remove (T item) |
Remove an item from the pool without cleaning it up. More... | |
void | Dispose () |
Destroy all objects in the pool. More... | |
Properties | |
Func< T > | CreateFunc [get, set] |
Function invoked to create an instance, which must not be null. More... | |
Action< T > | GetAction [get, set] |
Callback invoked when an object is retrieved from the pool. More... | |
Action< T > | ReleaseAction [get, set] |
Callback invoked when an object is returned to the pool. More... | |
Action< T > | DestroyAction [get, set] |
Callback invoked when an object is destroyed in the pool. More... | |
int | MaxCount = 0 [get, set] |
Max objects in pool, or 0 for no limit. More... | |
Provides a simple pool with an interface similar to the official Unity pool added in 2021.
T | Type of pooled object. |
Infohazard.Core.Pool< T >.Pool | ( | Func< T > | createFunc, |
Action< T > | getAction = null , |
||
Action< T > | releaseAction = null , |
||
Action< T > | destroyAction = null , |
||
int | maxCount = 0 |
||
) |
Create a new ObjectPool.
createFunc | Function invoked to create an instance, which must not be null. |
getAction | Callback invoked when an object is retrieved from the pool. |
releaseAction | Callback invoked when an object is returned to the pool. |
destroyAction | Callback invoked when an object is destroyed in the pool. |
maxCount | Max objects in pool, or 0 for no limit. |
void Infohazard.Core.Pool< T >.Clear | ( | ) |
Destroy all objects in the pool.
void Infohazard.Core.Pool< T >.Dispose | ( | ) |
Destroy all objects in the pool.
T Infohazard.Core.Pool< T >.Get | ( | ) |
Retrieve an item from the pool, creating a new one if necessary.
void Infohazard.Core.Pool< T >.Release | ( | T | item | ) |
Return an object to the pool, destroying it if over max count.
item | The object to release. |
void Infohazard.Core.Pool< T >.Remove | ( | T | item | ) |
Remove an item from the pool without cleaning it up.
item | Item to remove. |
|
getset |
Function invoked to create an instance, which must not be null.
|
getset |
Callback invoked when an object is destroyed in the pool.
|
getset |
Callback invoked when an object is retrieved from the pool.
|
getset |
Max objects in pool, or 0 for no limit.
|
getset |
Callback invoked when an object is returned to the pool.