Class TweenManager
Centralized static registry that drives automatic frame-by-frame updates for all managed ITween instances and provides target-based batch operations.
Inherited Members
Namespace: Scylla.Core.Util.Tween
Assembly: ScyllaCore.dll
Syntax
public static class TweenManager
Remarks
A tween becomes managed when SetManaged(bool) is set to true
and Play() is called, which calls Register(ITween)
internally. From that point, Update(float) must be called once per frame
(typically from a MonoBehaviour's Update or LateUpdate).
Update(float) is the recommended entry point for this call.
Target tracking: when a tween has a non-null Target, it is also indexed in an internal dictionary keyed by target. This enables the batch operations (KillTweensByTarget(object, bool), PauseTweensByTarget(object), ResumeTweensByTarget(object), GetTweensByTarget(object)) to operate in O(1) target lookup time.
During Update(float), destroyed Unity objects are detected by checking
whether the Target is a UnityEngine.Object whose
native handle is invalid. Such tweens are silently removed without callbacks.
Clear() can be used during scene transitions to wipe all tracking state without invoking any callbacks. For a clean teardown that respects callbacks use KillAll(bool) instead.
Properties
ActiveTweenCount
Gets the number of ITween instances currently registered with the manager and receiving automatic updates.
Declaration
public static int ActiveTweenCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
IsUpdating
Gets whether the manager is currently inside its Update(float) iteration.
Declaration
public static bool IsUpdating { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Remarks
While true, calls to Unregister(ITween) are deferred to the end of
the current update pass to prevent invalidating the iteration.
Methods
Clear()
Removes all managed tweens from every internal tracking structure without invoking any kill, complete, or loop callbacks.
Declaration
public static void Clear()
Remarks
Use this for hard resets during scene transitions where callback side-effects would cause errors (e.g., accessing destroyed GameObjects). For a clean teardown that respects callbacks, use KillAll(bool) instead.
CompleteAll()
Immediately completes every managed tween that is not already complete or killed, jumping each to its final value and firing its OnComplete(Action) callback.
Declaration
public static int CompleteAll()
Returns
| Type | Description |
|---|---|
| int | The number of tweens that were completed. |
GetTween(TweenID)
Looks up a managed tween by its unique TweenID.
Declaration
public static ITween GetTween(TweenID id)
Parameters
| Type | Name | Description |
|---|---|---|
| TweenID | id | The TweenID to search for. |
Returns
| Type | Description |
|---|---|
| ITween | The matching ITween if it is currently registered;
|
GetTweensByTarget(object)
Returns all managed tweens whose Target equals
target.
Declaration
public static IReadOnlyList<ITween> GetTweensByTarget(object target)
Parameters
| Type | Name | Description |
|---|---|---|
| object | target | The target object to query. If |
Returns
| Type | Description |
|---|---|
| IReadOnlyList<ITween> | A read-only list of ITween instances associated with the target, or an empty list if the target has no active tweens. The returned list is the manager's internal list and should not be modified. |
HasTweens(object)
Returns true if target has at least one managed tween
currently registered with the manager.
Declaration
public static bool HasTweens(object target)
Parameters
| Type | Name | Description |
|---|---|---|
| object | target | The target object to query. Returns |
Returns
| Type | Description |
|---|---|
| bool |
|
KillAll(bool)
Kills every managed tween currently registered with the manager.
Declaration
public static int KillAll(bool complete = false)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | complete | When |
Returns
| Type | Description |
|---|---|
| int | The number of tweens that were killed. |
KillTweensByTarget(object, bool)
Kills every managed tween whose Target equals
target.
Declaration
public static int KillTweensByTarget(object target, bool complete = false)
Parameters
| Type | Name | Description |
|---|---|---|
| object | target | The owner object whose tweens should be killed. Returns |
| bool | complete | When |
Returns
| Type | Description |
|---|---|
| int | The number of tweens that were killed. |
PauseAll()
Pauses every currently playing managed tween.
Declaration
public static int PauseAll()
Returns
| Type | Description |
|---|---|
| int | The number of tweens that were paused (already-paused tweens are not counted). |
PauseTweensByTarget(object)
Pauses every currently playing managed tween whose Target
equals target.
Declaration
public static int PauseTweensByTarget(object target)
Parameters
| Type | Name | Description |
|---|---|---|
| object | target | The owner object whose tweens should be paused. Returns |
Returns
| Type | Description |
|---|---|
| int | The number of tweens that were paused (already-paused tweens are not counted). |
Register(ITween)
Adds tween to the managed update list so that
Update(float) advances it automatically each frame.
Declaration
public static void Register(ITween tween)
Parameters
| Type | Name | Description |
|---|---|---|
| ITween | tween | The tween to register. Ignored if |
Remarks
If the tween has a non-null Target, it is also added to the target-indexed lookup so that batch operations such as KillTweensByTarget(object, bool) can find it efficiently.
ResumeAll()
Resumes every paused managed tween.
Declaration
public static int ResumeAll()
Returns
| Type | Description |
|---|---|
| int | The number of tweens that were resumed (already-playing tweens are not counted). |
ResumeTweensByTarget(object)
Resumes every paused managed tween whose Target equals
target.
Declaration
public static int ResumeTweensByTarget(object target)
Parameters
| Type | Name | Description |
|---|---|---|
| object | target | The owner object whose tweens should be resumed. Returns |
Returns
| Type | Description |
|---|---|
| int | The number of tweens that were resumed (already-playing tweens are not counted). |
Unregister(ITween)
Removes tween from the managed update list so it no longer
receives automatic Update(float) calls.
Declaration
public static void Unregister(ITween tween)
Parameters
| Type | Name | Description |
|---|---|---|
| ITween | tween | The tween to remove. Ignored if |
Remarks
If called while IsUpdating is true (i.e., from within a tween
callback or update), the removal is deferred until the end of the current update
pass to prevent iterator invalidation. Otherwise, the tween is removed immediately.
Update(float)
Advances all registered managed tweens by deltaTime seconds and
removes tweens that have been killed, completed with auto-kill enabled, or whose
Unity target object has been destroyed.
Declaration
public static void Update(float deltaTime)
Parameters
| Type | Name | Description |
|---|---|---|
| float | deltaTime | The elapsed time in seconds since the last call, typically
|
Remarks
The method iterates the active list in reverse order so that removals during the loop do not cause index skipping. Any exception thrown by a tween's Update(float) is caught, logged, and causes that tween to be removed from management.
Deferred removals collected while IsUpdating is true are
processed at the end of this method before the flag is cleared.
This method is a no-op when there are no active tweens.