Interface ITween
Core interface implemented by all tween types in the Scylla Tween system.
Namespace: Scylla.Core.Util.Tween
Assembly: ScyllaCore.dll
Syntax
public interface ITween
Remarks
ITween defines the complete contract for a single animation tween: its observable
state, timing and looping configuration, lifecycle control, and callback registration.
All concrete tween types (TweenFloat, TweenVector3, TweenColor,
etc.) and the TweenSequence implement this interface through
TweenBase.
Managed vs. manual tweens
A tween whose IsManaged flag is true is registered with the
TweenManager and is ticked automatically each frame via
ScyllaTween.Update(deltaTime). A manual tween must have
Update(float) called explicitly by the caller every frame.
Method chaining
All configuration and callback methods return ITween (the same instance) so
they can be chained in a fluent style:
<pre><code class="lang-csharp">ScyllaTween.To(() => transform.position, v => transform.position = v, target, 0.5f)
.SetEase(EaseType.OutBack)
.SetDelay(0.1f)
.SetManaged(true)
.OnComplete(() => Debug.Log("Done"))
.Play();</code></pre>
Lifecycle
The tween moves through states defined by TweenState:
Created -> Delayed (optional) -> Playing -> Complete -> Killed.
It may also transition to Paused from Playing or Delayed.
Once a tween reaches Killed it should be treated as invalid and released back
to the pool.
Properties
AutoKill
Gets whether this tween is automatically killed when it completes.
Declaration
bool AutoKill { get; }
Property Value
| Type | Description |
|---|---|
| bool | When |
CompletedLoops
Gets the number of loop iterations that have fully completed so far.
Declaration
int CompletedLoops { get; }
Property Value
| Type | Description |
|---|---|
| int | Incremented each time a full forward (or reverse, for Yoyo)
pass of the tween finishes. Resets to |
Delay
Gets the initial delay in seconds before the tween begins playing after Play() is called.
Declaration
float Delay { get; }
Property Value
| Type | Description |
|---|---|
| float | While the delay is counting down the tween is in Delayed
state and IsPlaying returns |
Duration
Gets the total playback duration of the tween in seconds, excluding any delay.
Declaration
float Duration { get; }
Property Value
| Type | Description |
|---|---|
| float | The number of seconds from when playback begins (after the delay elapses) until the
tween reaches its end value. A duration of |
EaseType
Gets the EaseType that controls the interpolation curve of this tween.
Declaration
EaseType EaseType { get; }
Property Value
| Type | Description |
|---|---|
| EaseType | Determines how the animated value accelerates and decelerates over the tween's duration. When set to Custom, a user-supplied delegate is used instead. Change via SetEase(EaseType) or SetEase(Func<float, float>). Defaults to DefaultEaseType (initially OutQuad). |
ElapsedTime
Gets the amount of time that has elapsed during active playback, in seconds.
Declaration
float ElapsedTime { get; }
Property Value
| Type | Description |
|---|---|
| float | The running total of scaled delta time accumulated while the tween is in the
Playing state. Delay time is tracked separately and is
not included in this value. Ranges from |
ID
Gets the unique identifier assigned to this tween instance.
Declaration
TweenID ID { get; }
Property Value
| Type | Description |
|---|---|
| TweenID | A TweenID that is globally unique for the lifetime of the application. The ID is generated at construction time (or at pool-reset time) and does not change while the tween is alive. Use it to look up a tween via GetTween(TweenID) or GetTween(TweenID). |
IsComplete
Gets whether the tween has run to completion and reached its end value.
Declaration
bool IsComplete { get; }
Property Value
| Type | Description |
|---|---|
| bool | Returns |
IsKilled
Gets whether the tween has been killed and is no longer usable.
Declaration
bool IsKilled { get; }
Property Value
| Type | Description |
|---|---|
| bool | Returns |
IsManaged
Gets whether this tween is registered with and automatically updated by the TweenManager.
Declaration
bool IsManaged { get; }
Property Value
| Type | Description |
|---|---|
| bool |
|
IsPaused
Gets whether the tween is currently paused.
Declaration
bool IsPaused { get; }
Property Value
| Type | Description |
|---|---|
| bool | Returns |
IsPlaying
Gets whether the tween is currently in an active playback state.
Declaration
bool IsPlaying { get; }
Property Value
| Type | Description |
|---|---|
| bool | Returns |
LoopType
Gets the LoopType that controls how the tween behaves at the end of each loop iteration.
Declaration
LoopType LoopType { get; }
Property Value
| Type | Description |
|---|---|
| LoopType | Only meaningful when Loops is non-zero. Set via SetLoops(int, LoopType). Defaults to Restart. |
See Also
Loops
Gets the total number of loop iterations the tween will execute.
Declaration
int Loops { get; }
Property Value
| Type | Description |
|---|---|
| int |
Set via SetLoops(int, LoopType). |
Progress
Gets the normalized playback progress as a value clamped between 0.0 and
1.0.
Declaration
float Progress { get; }
Property Value
| Type | Description |
|---|---|
| float | Computed as |
State
Gets the current lifecycle state of the tween.
Declaration
TweenState State { get; }
Property Value
| Type | Description |
|---|---|
| TweenState | One of the TweenState values that describes where the tween currently sits in its lifecycle. The convenience bool properties (IsPlaying, IsPaused, IsComplete, IsKilled) each test this value. |
See Also
Target
Gets the object that this tween is animating, or null if no target was set.
Declaration
object Target { get; }
Property Value
| Type | Description |
|---|---|
| object | Used by the TweenManager for target-based batch operations such as
KillTweensByTarget(object, bool) and
PauseTweensByTarget(object). It is also used to detect destroyed
Unity objects during the update loop; if the target is a |
TimeScale
Gets the per-tween time scale multiplier applied to delta time during updates.
Declaration
float TimeScale { get; }
Property Value
| Type | Description |
|---|---|
| float | Multiplied against the incoming delta time before advancing
ElapsedTime. For managed tweens the result is further multiplied by
GlobalTimeScale. A value of |
Methods
Complete()
Immediately advances the tween to its final value and transitions to Complete.
Declaration
ITween Complete()
Returns
| Type | Description |
|---|---|
| ITween | This tween instance, enabling fluent method chaining. |
Remarks
Sets ElapsedTime to Duration, applies the end value,
and fires the OnComplete(Action) callback. If AutoKill is
true, Kill(bool) is subsequently called automatically. Has no effect
on a tween that is already killed or complete.
Kill(bool)
Permanently stops the tween and transitions it to Killed.
Declaration
ITween Kill(bool complete = false)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | complete | When |
Returns
| Type | Description |
|---|---|
| ITween | This tween instance, enabling fluent method chaining. |
Remarks
Calling Kill on an already-killed tween is a no-op. After killing, the
OnKill(Action) callback is fired. Managed tweens are automatically
unregistered from the TweenManager.
A killed tween should not be used further. If the tween was obtained from the
pool it will be returned automatically when AutoKill is
true; otherwise, the pool handles reclamation after the kill callback.
OnComplete(Action)
Registers a callback that is invoked when all loop iterations have finished and the tween reaches Complete.
Declaration
ITween OnComplete(Action callback)
Parameters
| Type | Name | Description |
|---|---|---|
| Action | callback | The action to invoke. Exceptions thrown by the callback are caught and logged but do not stop the tween. |
Returns
| Type | Description |
|---|---|
| ITween | This tween instance, enabling fluent method chaining. |
Remarks
Fires once when the very last iteration ends. For per-iteration completion
notification see OnLoopComplete(Action). If AutoKill is
true, Kill(bool) is called immediately after this callback returns.
OnKill(Action)
Registers a callback that is invoked when the tween is killed via Kill(bool).
Declaration
ITween OnKill(Action callback)
Parameters
| Type | Name | Description |
|---|---|---|
| Action | callback | The action to invoke on kill. Exceptions thrown by the callback are caught and
logged. Fires regardless of whether the tween was killed with
|
Returns
| Type | Description |
|---|---|
| ITween | This tween instance, enabling fluent method chaining. |
OnLoopComplete(Action)
Registers a callback that is invoked at the end of each individual loop iteration, including all but the very last iteration.
Declaration
ITween OnLoopComplete(Action callback)
Parameters
| Type | Name | Description |
|---|---|---|
| Action | callback | The action to invoke each time a loop iteration completes. Exceptions thrown by the callback are caught and logged. |
Returns
| Type | Description |
|---|---|
| ITween | This tween instance, enabling fluent method chaining. |
Remarks
This callback fires once per completed iteration when Loops is non-zero. It does not fire on the final completion - use OnComplete(Action) for that.
OnPause(Action)
Registers a callback that is invoked when the tween is paused via Pause().
Declaration
ITween OnPause(Action callback)
Parameters
| Type | Name | Description |
|---|---|---|
| Action | callback | The action to invoke when the tween transitions into Paused state. Exceptions thrown by the callback are caught and logged. |
Returns
| Type | Description |
|---|---|
| ITween | This tween instance, enabling fluent method chaining. |
OnResume(Action)
Registers a callback that is invoked when a paused tween is resumed via Play().
Declaration
ITween OnResume(Action callback)
Parameters
| Type | Name | Description |
|---|---|---|
| Action | callback | The action to invoke when the tween transitions out of Paused back into Playing or Delayed. Exceptions thrown by the callback are caught and logged. |
Returns
| Type | Description |
|---|---|
| ITween | This tween instance, enabling fluent method chaining. |
OnStart(Action)
Registers a callback that is invoked once when the tween transitions from the delay phase (or directly from Created) into Playing for the first time.
Declaration
ITween OnStart(Action callback)
Parameters
| Type | Name | Description |
|---|---|---|
| Action | callback | The action to invoke. Exceptions thrown by the callback are caught and logged but do not stop the tween. |
Returns
| Type | Description |
|---|---|
| ITween | This tween instance, enabling fluent method chaining. |
Remarks
This callback fires exactly once per Play() call, after any configured Delay has elapsed. Calling Restart() resets the internal flag, so the callback fires again on the next start.
OnUpdate(Action)
Registers a callback that is invoked after each frame in which the tween advances its animated value.
Declaration
ITween OnUpdate(Action callback)
Parameters
| Type | Name | Description |
|---|---|---|
| Action | callback | The action to invoke on every update tick while the tween is playing. Exceptions thrown by the callback are caught and logged but do not stop the tween. |
Returns
| Type | Description |
|---|---|
| ITween | This tween instance, enabling fluent method chaining. |
Remarks
The callback fires after the animated property has been updated with the new eased value, so the property's current value reflects the just-applied interpolation when the callback runs.
Pause()
Pauses the tween, suspending updates while preserving elapsed time.
Declaration
ITween Pause()
Returns
| Type | Description |
|---|---|
| ITween | This tween instance, enabling fluent method chaining. |
Remarks
Only effective when the tween is in Playing or Delayed state. Fires the OnPause(Action) callback. The tween can be resumed by calling Play() again.
Play()
Starts or resumes the tween, transitioning it into an active playback state.
Declaration
ITween Play()
Returns
| Type | Description |
|---|---|
| ITween | This tween instance, enabling fluent method chaining. |
Remarks
The behaviour of Play depends on the tween's current state:
- Created or Complete - begins playback from the start. If a Delay greater than zero is configured, the tween first enters Delayed before moving to Playing. If the tween is managed it is registered with the TweenManager at this point.
- Paused - resumes from the saved ElapsedTime and fires the OnResume(Action) callback.
- Killed - no-op; a killed tween cannot be replayed without resetting it first.
Reset()
Resets all tween state back to initial defaults, preparing the instance for reuse from a pool.
Declaration
void Reset()
Remarks
Clears all callbacks, resets timing values, generates a new TweenID,
and sets State back to Created. This is
called automatically by the tween pool (TweenPool) before returning an
instance to a caller. Derived classes that override this method must call the base
implementation.
Restart()
Restarts the tween from the very beginning, resetting all timing and loop state.
Declaration
ITween Restart()
Returns
| Type | Description |
|---|---|
| ITween | This tween instance, enabling fluent method chaining. |
Remarks
Resets ElapsedTime, CompletedLoops, and any Yoyo-reverse flag back to their initial values, then immediately begins playback (respecting the configured Delay). If the tween is managed it re-registers with the TweenManager if not already active.
Rewind()
Resets the tween's elapsed time and applies the start value without changing the tween's active/paused state.
Declaration
ITween Rewind()
Returns
| Type | Description |
|---|---|
| ITween | This tween instance, enabling fluent method chaining. |
Remarks
Unlike Restart(), Rewind does not begin playback. The tween
stays in whatever state it is currently in (playing, paused, etc.) but
ElapsedTime is reset to 0, CompletedLoops is
cleared, and the interpolated value is set back to the starting value.
SetAutoKill(bool)
Controls whether this tween is automatically killed and returned to the pool when it completes.
Declaration
ITween SetAutoKill(bool autoKill)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | autoKill |
|
Returns
| Type | Description |
|---|---|
| ITween | This tween instance, enabling fluent method chaining. |
SetDelay(float)
Sets the delay in seconds that elapses before playback begins after Play() is called.
Declaration
ITween SetDelay(float delay)
Parameters
| Type | Name | Description |
|---|---|---|
| float | delay | Duration of the delay in seconds. Negative values are clamped to |
Returns
| Type | Description |
|---|---|
| ITween | This tween instance, enabling fluent method chaining. |
SetEase(EaseType)
Sets the easing curve used to interpolate the animated value over the tween's duration.
Declaration
ITween SetEase(EaseType easeType)
Parameters
| Type | Name | Description |
|---|---|---|
| EaseType | easeType | The predefined easing curve to apply. All standard Robert Penner easing functions are supported, plus Linear and Flash. Passing Custom without also calling SetEase(Func<float, float>) will result in a no-op custom function. |
Returns
| Type | Description |
|---|---|
| ITween | This tween instance, enabling fluent method chaining. |
SetEase(Func<float, float>)
Sets a fully custom easing function for fine-grained control over interpolation.
Declaration
ITween SetEase(Func<float, float> easeFunction)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<float, float> | easeFunction | A delegate that accepts a normalized time value |
Returns
| Type | Description |
|---|---|
| ITween | This tween instance, enabling fluent method chaining. |
SetLoops(int, LoopType)
Configures how many times the tween repeats and how it behaves between iterations.
Declaration
ITween SetLoops(int loops, LoopType loopType = LoopType.Restart)
Parameters
| Type | Name | Description |
|---|---|---|
| int | loops | The number of loop iterations to execute:
|
| LoopType | loopType | Controls how the tween transitions between iterations. Defaults to Restart. |
Returns
| Type | Description |
|---|---|
| ITween | This tween instance, enabling fluent method chaining. |
See Also
SetManaged(bool)
Controls whether this tween is automatically updated by the TweenManager each frame.
Declaration
ITween SetManaged(bool managed)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | managed |
|
Returns
| Type | Description |
|---|---|
| ITween | This tween instance, enabling fluent method chaining. |
SetTimeScale(float)
Sets the per-tween time scale that is multiplied against incoming delta time during each Update(float) call.
Declaration
ITween SetTimeScale(float timeScale)
Parameters
| Type | Name | Description |
|---|---|---|
| float | timeScale | The time scale multiplier. Values greater than |
Returns
| Type | Description |
|---|---|
| ITween | This tween instance, enabling fluent method chaining. |
Update(float)
Advances the tween by the given amount of time, updating the animated value.
Declaration
void Update(float deltaTime)
Parameters
| Type | Name | Description |
|---|---|---|
| float | deltaTime | The time elapsed since the last update call, in seconds. Must be non-negative.
For manual tweens this is typically |
Remarks
The supplied deltaTime is scaled by the tween's own
TimeScale. For managed tweens it is additionally scaled by
GlobalTimeScale before being applied.
If the tween is not in Playing or Delayed state, this method is a no-op.