Class TweenPool
Static façade over a set of ScyllaGenericObjectPool<T> instances, one per concrete tween type, that allows tween instances to be reused instead of heap-allocated on every animation request.
Inherited Members
Namespace: Scylla.Core.Util.Tween
Assembly: ScyllaCore.dll
Syntax
public static class TweenPool
Remarks
The pool is not initialized automatically. Call Initialize() (or the
overload) once at application startup before creating any tweens. Calling any
Get method before initialization will trigger a lazy initialization with
default settings via DefaultPoolCapacity and
DefaultPoolMaxSize.
The recommended entry point for initialization is Initialize(), which delegates to this class.
Usage pattern:
- Obtain an instance via a typed
Get*method (e.g., GetFloat(), GetSequence()). - Configure and play the tween.
- When done, release back to the pool with the matching typed Release(TweenFloat) overload.
TweenPool calls Reset() on the instance before it is
returned to the pool so that the next consumer starts with a clean state.
The TweenSequence sub-pool is pre-allocated at half the capacity and half the maximum size of the value-type pools, since sequences are typically less numerous than individual tweens. The same ratio applies to Prewarm(int).
Properties
FloatPoolCount
Gets the number of TweenFloat instances currently sitting idle in the pool, ready to be retrieved without a heap allocation.
Declaration
public static int FloatPoolCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
IsInitialized
Gets whether the pool system has been initialized via Initialize() or Initialize(int, int).
Declaration
public static bool IsInitialized { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Vector3PoolCount
Gets the number of TweenVector3 instances currently sitting idle in the pool, ready to be retrieved without a heap allocation.
Declaration
public static int Vector3PoolCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
Clear()
Empties every sub-pool, discarding all currently idle instances.
Declaration
public static void Clear()
Remarks
Only pools that have been initialized are cleared. This method does not reset
IsInitialized, so subsequent Get* calls will still work.
Use this in combination with Clear() during a full
teardown to free pooled memory.
GetColor()
Retrieves a TweenColor instance from the pool, triggering lazy initialization if needed.
Declaration
public static TweenColor GetColor()
Returns
| Type | Description |
|---|---|
| TweenColor | A TweenColor in the Created state. |
GetFloat()
Retrieves a TweenFloat instance from the pool, triggering lazy initialization with default settings if the pool has not yet been set up.
Declaration
public static TweenFloat GetFloat()
Returns
| Type | Description |
|---|---|
| TweenFloat | A TweenFloat in the Created state, ready to be configured and played. |
GetQuaternion()
Retrieves a TweenQuaternion instance from the pool, triggering lazy initialization if needed.
Declaration
public static TweenQuaternion GetQuaternion()
Returns
| Type | Description |
|---|---|
| TweenQuaternion | A TweenQuaternion in the Created state. |
GetSequence()
Retrieves a TweenSequence instance from the pool, triggering lazy initialization if needed.
Declaration
public static TweenSequence GetSequence()
Returns
| Type | Description |
|---|---|
| TweenSequence | A TweenSequence in the Created state with an empty item list, ready to have tweens, callbacks, and intervals added to it. |
Remarks
This is the method called internally by Sequence(). Prefer that entry point in application code.
GetVector2()
Retrieves a TweenVector2 instance from the pool, triggering lazy initialization if needed.
Declaration
public static TweenVector2 GetVector2()
Returns
| Type | Description |
|---|---|
| TweenVector2 | A TweenVector2 in the Created state. |
GetVector3()
Retrieves a TweenVector3 instance from the pool, triggering lazy initialization if needed.
Declaration
public static TweenVector3 GetVector3()
Returns
| Type | Description |
|---|---|
| TweenVector3 | A TweenVector3 in the Created state. |
GetVector4()
Retrieves a TweenVector4 instance from the pool, triggering lazy initialization if needed.
Declaration
public static TweenVector4 GetVector4()
Returns
| Type | Description |
|---|---|
| TweenVector4 | A TweenVector4 in the Created state. |
Initialize()
Initializes all tween sub-pools using the current values of DefaultPoolCapacity and DefaultPoolMaxSize.
Declaration
public static void Initialize()
Remarks
This overload is a convenience wrapper around Initialize(int, int). Call it once at application startup - ideally via Initialize() - for best performance. Subsequent calls are no-ops.
Initialize(int, int)
Initializes all tween sub-pools with the specified capacity settings.
Declaration
public static void Initialize(int initialCapacity, int maxSize)
Parameters
| Type | Name | Description |
|---|---|---|
| int | initialCapacity | The number of instances to pre-allocate in each value-type pool on startup. The TweenSequence pool is initialized at half this value. |
| int | maxSize | The maximum number of idle instances each value-type pool may hold. Instances released beyond this limit are discarded and garbage-collected. The sequence pool cap is half this value. |
Remarks
This method is a no-op if the pool has already been initialized. To reinitialize with different settings, call Clear() first, then call this method again - or simply configure TweenSettings before the first initialization.
Prewarm(int)
Pre-allocates tween instances into every sub-pool so that the first batch of animation requests does not incur heap allocation overhead.
Declaration
public static void Prewarm(int count)
Parameters
| Type | Name | Description |
|---|---|---|
| int | count | The number of instances to pre-allocate in each value-type pool. The sequence
pool receives |
Release(TweenColor)
Resets tween and returns it to the Color pool for future reuse.
Declaration
public static void Release(TweenColor tween)
Parameters
| Type | Name | Description |
|---|---|---|
| TweenColor | tween | The TweenColor to release. Ignored if |
Release(TweenFloat)
Resets tween and returns it to the float pool for future reuse.
Declaration
public static void Release(TweenFloat tween)
Parameters
| Type | Name | Description |
|---|---|---|
| TweenFloat | tween | The TweenFloat to release. Ignored if |
Release(TweenQuaternion)
Resets tween and returns it to the Quaternion pool for future reuse.
Declaration
public static void Release(TweenQuaternion tween)
Parameters
| Type | Name | Description |
|---|---|---|
| TweenQuaternion | tween | The TweenQuaternion to release. Ignored if |
Release(TweenSequence)
Resets sequence and returns it to the sequence pool for future reuse.
Declaration
public static void Release(TweenSequence sequence)
Parameters
| Type | Name | Description |
|---|---|---|
| TweenSequence | sequence | The TweenSequence to release. Ignored if |
Release(TweenVector2)
Resets tween and returns it to the Vector2 pool for future reuse.
Declaration
public static void Release(TweenVector2 tween)
Parameters
| Type | Name | Description |
|---|---|---|
| TweenVector2 | tween | The TweenVector2 to release. Ignored if |
Release(TweenVector3)
Resets tween and returns it to the Vector3 pool for future reuse.
Declaration
public static void Release(TweenVector3 tween)
Parameters
| Type | Name | Description |
|---|---|---|
| TweenVector3 | tween | The TweenVector3 to release. Ignored if |
Release(TweenVector4)
Resets tween and returns it to the Vector4 pool for future reuse.
Declaration
public static void Release(TweenVector4 tween)
Parameters
| Type | Name | Description |
|---|---|---|
| TweenVector4 | tween | The TweenVector4 to release. Ignored if |