Summary
A simple object pooling system.
- Assembly
- Animancer
.dll - Namespace
- Animancer
- Base Types
-
- Object
- Derived Types
graph BT
Type-->Base0["Object"]
Type["ObjectPool<T>"]
class Type type-node
Derived0["PooledGUIContent.Pool"]-->Type
click Derived0 "/animancer/api/Animancer.Editor/Pool"
Derived1["StringBuilderPool"]-->Type
click Derived1 "/animancer/api/Animancer/StringBuilderPool"
Derived2["CollectionPool<TItem, TCollection>"]-->Type
click Derived2 "/animancer/api/Animancer/CollectionPool_2"
Derived3["FadeGroup.Pool"]-->Type
click Derived3 "/animancer/api/Animancer/Pool"
Derived4["CloneContext.Pool"]-->Type
click Derived4 "/animancer/api/Animancer/Pool"
Syntax
public class ObjectPool<T> where T : class
Remarks
T must not inherit from
UnityEngine.Component or UnityEngine.ScriptableObject.Type Parameters
| Name | Description |
|---|---|
| T |
Constructors
| Name | Summary |
|---|---|
| ObjectPool |
Creates a new Animancer.ObjectPool`1
and asserts that there isn't a more derived type which should be used instead.
|
Fields
| Name | Constant Value | Summary |
|---|---|---|
| NotResetError | It must be reset to its default values before being released to the pool and not modified after that. |
An error message for when something has been modified after being released to the pool.
static
|
Properties
| Name | Value | Summary |
|---|---|---|
| Capacity | int |
The
System.Collections.Generic.List`1.Capacity of the internal list of spare items. |
| Count | int |
The number of spare items currently in this pool.
|
| DefaultInstance | ObjectPool |
Returns the
Animancer.Static`1.Instance.static
|
Methods
| Name | Value | Summary |
|---|---|---|
| Acquire |
T |
Returns a spare item if there are any, or creates a new one.
|
| Acquire |
ObjectPool |
Creates a new
Animancer.ObjectPool`1.Disposable and calls Animancer.ObjectPool`1.Acquire
to set the Animancer.ObjectPool`1.Disposable.Item and `item`.
|
| IncreaseCapacityTo |
void |
Increases the
Animancer.ObjectPool`1.Capacity to equal the `capacity` if it was lower. |
| IncreaseCountTo |
void |
Increases the
Animancer.ObjectPool`1.Count to equal the `count` if it was lower. |
| New |
T |
Creates a
new() instance of T. |
| Release |
void |
Adds the `item` to the list of spares so it can be reused.
|
| Release |
void |
Adds the `item` to the list of spares so it can be reused and sets it to
null. |
| ToString |
string |
Returns a description of the state of this pool.
|