Class TweenLerp
Provides optimized, type-specific interpolation functions used internally by the Scylla tween engine to compute animated property values each frame.
All standard interpolation methods use manual arithmetic rather than Unity's
Mathf.Lerp / Vector3.Lerp equivalents because those APIs clamp
t to [0, 1]. The tween engine passes eased progress values that
may legitimately exceed this range when using overshoot easing types such as
InElastic, OutBack, and their
variants. Unclamped arithmetic correctly propagates overshoot into the
interpolated output.
Incremental variants (e.g., FloatIncremental(float, float, float, int), Vector3Incremental(Vector3, Vector3, float, int)) are used when a tween's loop type is Incremental. Instead of interpolating between a fixed start and end value each pass, they accumulate a constant delta per completed loop iteration so the animated property advances monotonically over the entire animation lifetime.
These methods are not intended to be called directly by game code; use ScyllaTween factory methods to create tweens instead.
Inherited Members
Namespace: Scylla.Core.Util.Tween
Assembly: ScyllaCore.dll
Syntax
public static class TweenLerp
Methods
Angle(float, float, float)
Interpolates between two angles in degrees, automatically choosing the shortest
arc around the 360° circle using Mathf.DeltaAngle. Formula:
from + DeltaAngle(from, to) * t.
For example, interpolating from 350° to 10° with t = 0.5 yields 0°
(travelling 20° forward) rather than 180° (travelling 340° backward).
Unlike the other scalar lerp methods, t is applied to the
signed angular delta rather than the raw difference, so the result is always
the geometrically shortest rotation. The output angle is not normalised to
[0°, 360°) and may exceed those bounds.
Declaration
public static float Angle(float from, float to, float t)
Parameters
| Type | Name | Description |
|---|---|---|
| float | from | The start angle in degrees. |
| float | to | The end angle in degrees. |
| float | t | The interpolation factor produced by the easing function.
May be outside |
Returns
| Type | Description |
|---|---|
| float | The interpolated angle in degrees along the shortest arc from
|
Color(Color, Color, float)
Interpolates between two UnityEngine.Color values component-wise
in linear color space using unclamped arithmetic. All four channels (R, G, B, A)
are interpolated independently. Formula per channel:
from.c + (to.c - from.c) * t.
Because the arithmetic is unclamped, channels may briefly exceed [0, 1]
when an overshoot easing type is active. Unity's rendering pipeline clamps
color values when they are applied to materials or UI elements.
Declaration
public static Color Color(Color from, Color to, float t)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | from | The color at |
| Color | to | The color at |
| float | t | The interpolation factor produced by the easing function.
May be outside |
Returns
| Type | Description |
|---|---|
| Color | The component-wise interpolated color. Channel values may be outside
|
Color32(Color32, Color32, float)
Interpolates between two UnityEngine.Color32 values component-wise.
Each 8-bit channel is computed as a float and then truncated (cast) to
byte. Formula per channel: (byte)(from.c + (to.c - from.c) * t).
Note that the cast truncates rather than rounds, which may introduce a small
downward bias of up to one unit in each channel at certain t values.
For most animation purposes this is imperceptible. Use Color(Color, Color, float)
if sub-byte precision is important.
Declaration
public static Color32 Color32(Color32 from, Color32 to, float t)
Parameters
| Type | Name | Description |
|---|---|---|
| Color32 | from | The color at |
| Color32 | to | The color at |
| float | t | The interpolation factor produced by the easing function.
May be outside |
Returns
| Type | Description |
|---|---|
| Color32 | The component-wise interpolated Color32. |
ColorAlpha(Color, float, float)
Interpolates only the alpha channel of a UnityEngine.Color, keeping
the red, green, and blue channels unchanged from from. Formula:
alpha = from.a + (toAlpha - from.a) * t.
This is the method used internally by alpha-fade tweens (e.g.,
TweenCanvasGroupExtensions.DOFade) that animate only transparency
without modifying the color tint.
Declaration
public static Color ColorAlpha(Color from, float toAlpha, float t)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | from | The source color whose RGB channels are preserved in the output and whose alpha provides the starting value. |
| float | toAlpha | The target alpha value at |
| float | t | The interpolation factor produced by the easing function.
May be outside |
Returns
| Type | Description |
|---|---|
| Color | A color with RGB copied from |
Double(double, double, float)
Interpolates between two double values using unclamped linear
arithmetic. Formula: from + (to - from) * t.
The interpolation factor t is accepted as a float
(matching the tween engine's internal representation) and widened to
double precision during the calculation.
Declaration
public static double Double(double from, double to, float t)
Parameters
| Type | Name | Description |
|---|---|---|
| double | from | The value at |
| double | to | The value at |
| float | t | The interpolation factor produced by the easing function, as a |
Returns
| Type | Description |
|---|---|
| double | The interpolated double. May be outside |
EulerAngles(Vector3, Vector3, float)
Interpolates between two sets of Euler angles in degrees (represented as UnityEngine.Vector3) by applying Angle(float, float, float) independently to each axis. Each axis takes the shortest arc, so the X, Y, and Z rotations are minimised individually rather than as a combined quaternion.
For large or combined rotations, interpolating Euler angles per-axis can produce gimbal-lock artefacts. In those cases, prefer Quaternion(Quaternion, Quaternion, float) (Slerp) which operates in quaternion space.
Declaration
public static Vector3 EulerAngles(Vector3 from, Vector3 to, float t)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | from | The start Euler angles in degrees (X, Y, Z). |
| Vector3 | to | The end Euler angles in degrees (X, Y, Z). |
| float | t | The interpolation factor produced by the easing function.
May be outside |
Returns
| Type | Description |
|---|---|
| Vector3 | The per-axis shortest-arc interpolated Euler angles in degrees.
The output is not normalised to |
Float(float, float, float)
Interpolates between two float values using unclamped linear
arithmetic. Formula: from + (to - from) * t.
Declaration
public static float Float(float from, float to, float t)
Parameters
| Type | Name | Description |
|---|---|---|
| float | from | The value at |
| float | to | The value at |
| float | t | The interpolation factor produced by the easing function. May be outside
|
Returns
| Type | Description |
|---|---|
| float | The interpolated float. May be outside |
FloatIncremental(float, float, float, int)
Interpolates a float value in Incremental mode.
Rather than interpolating toward a fixed end value each pass, this method accumulates
a constant change per completed loop so that the output advances
monotonically. Formula: from + change * (completedLoops + t).
For example, with from = 0, change = 1, completedLoops = 2,
and t = 0.5, the result is 2.5 - the midpoint of the third iteration.
Declaration
public static float FloatIncremental(float from, float change, float t, int completedLoops)
Parameters
| Type | Name | Description |
|---|---|---|
| float | from | The original start value at the beginning of the very first loop iteration. |
| float | change | The total distance travelled in one complete loop iteration (i.e., |
| float | t | The normalized time within the current loop iteration, produced by the easing function.
May be outside |
| int | completedLoops | The number of loop iterations that have fully completed before the current one. Sourced from CompletedLoops. |
Returns
| Type | Description |
|---|---|
| float | The accumulated float value for the current frame. |
Int(int, int, float)
Interpolates between two int values and rounds the continuous result
to the nearest integer using banker's rounding (midpoint rounds to even) via
Mathf.RoundToInt. Formula: round(from + (to - from) * t).
Because integers are discrete, the output changes in steps as t
advances. This is intentional and produces a staircase effect that is typically
correct for counter-style animations (e.g., score displays).
Declaration
public static int Int(int from, int to, float t)
Parameters
| Type | Name | Description |
|---|---|---|
| int | from | The integer value at |
| int | to | The integer value at |
| float | t | The interpolation factor produced by the easing function.
May be outside |
Returns
| Type | Description |
|---|---|
| int | The interpolated integer, rounded to the nearest whole number.
May be outside |
Quaternion(Quaternion, Quaternion, float)
Interpolates between two UnityEngine.Quaternion rotations using spherical linear interpolation (Slerp) in its unclamped form. Slerp moves along the great-circle arc between the two orientations at a constant angular velocity, producing the most natural-looking rotation for most use cases.
Delegates to Quaternion.SlerpUnclamped so that overshoot easing types
correctly rotate past the end orientation by a proportional angle.
Declaration
public static Quaternion Quaternion(Quaternion from, Quaternion to, float t)
Parameters
| Type | Name | Description |
|---|---|---|
| Quaternion | from | The rotation at |
| Quaternion | to | The rotation at |
| float | t | The interpolation factor produced by the easing function.
May be outside |
Returns
| Type | Description |
|---|---|
| Quaternion | The spherically interpolated rotation. When |
QuaternionLinear(Quaternion, Quaternion, float)
Interpolates between two UnityEngine.Quaternion rotations using normalized linear interpolation (Nlerp) in its unclamped form. Nlerp is computationally cheaper than Quaternion(Quaternion, Quaternion, float) (Slerp) but does not maintain constant angular velocity - the apparent rotation speed varies slightly across the arc. The deviation is most noticeable for very large angles (close to 180°) and is imperceptible for small rotations.
Delegates to Quaternion.LerpUnclamped so that overshoot easing types
produce the expected angular overshoot.
Prefer Quaternion(Quaternion, Quaternion, float) (Slerp) for cinematic camera moves or precise mechanical rotations. Use this method when performance is critical and rotation angles are small.
Declaration
public static Quaternion QuaternionLinear(Quaternion from, Quaternion to, float t)
Parameters
| Type | Name | Description |
|---|---|---|
| Quaternion | from | The rotation at |
| Quaternion | to | The rotation at |
| float | t | The interpolation factor produced by the easing function.
May be outside |
Returns
| Type | Description |
|---|---|
| Quaternion | The linearly interpolated and normalised rotation. When |
Rect(Rect, Rect, float)
Interpolates between two UnityEngine.Rect values by independently
interpolating each of the four components (x, y, width, height) using unclamped
linear arithmetic. Formula per component: from.c + (to.c - from.c) * t.
Useful for animating UI layout elements such as scrollable areas, panel bounds, or camera viewport rectangles.
Declaration
public static Rect Rect(Rect from, Rect to, float t)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | from | The rect at |
| Rect | to | The rect at |
| float | t | The interpolation factor produced by the easing function.
May be outside |
Returns
| Type | Description |
|---|---|
| Rect | The component-wise interpolated rect. Components may exceed the range defined by
|
String(string, string, float)
Creates a text-reveal effect by returning a progressively longer prefix of the
target string to. The number of revealed characters is
determined by round(to.Length * clamp01(t)), so the entire string is
visible at t = 1 and no characters are visible at t = 0.
Unlike other TweenLerp methods, t is clamped to
[0, 1] before use because negative or greater-than-one character
counts are meaningless for string indexing. The from
parameter is preserved for API consistency with other lerp signatures but
is only returned when to is null or empty.
Declaration
public static string String(string from, string to, float t)
Parameters
| Type | Name | Description |
|---|---|---|
| string | from | The source string. Returned as-is (or as Empty if null)
when |
| string | to | The full target string to reveal. If null or empty, |
| float | t | The interpolation factor. Values below |
Returns
| Type | Description |
|---|---|
| string | A substring of |
Typewriter(string, float)
Creates a typewriter effect that gradually reveals the characters of
text from left to right. The number of visible characters
is determined by round(text.Length * clamp01(t)).
Unlike String(string, string, float), this method takes a single string target
with no from parameter, making it more convenient for one-way
typewriter animations where there is no meaningful starting string.
Returns Empty immediately when text
is null or empty.
Declaration
public static string Typewriter(string text, float t)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text | The full text to reveal character by character. |
| float | t | The interpolation factor in |
Returns
| Type | Description |
|---|---|
| string | A prefix of |
Vector2(Vector2, Vector2, float)
Interpolates between two UnityEngine.Vector2 values component-wise
using unclamped linear arithmetic. Each component is computed independently as
from.x + (to.x - from.x) * t, etc.
Declaration
public static Vector2 Vector2(Vector2 from, Vector2 to, float t)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | from | The vector at |
| Vector2 | to | The vector at |
| float | t | The interpolation factor produced by the easing function.
May be outside |
Returns
| Type | Description |
|---|---|
| Vector2 | The component-wise interpolated vector. Individual components may exceed the range
|
Vector2Incremental(Vector2, Vector2, float, int)
Interpolates a UnityEngine.Vector2 value in
Incremental mode. Accumulates a constant
change vector per completed loop iteration. Each component
uses the formula from.n + change.n * (completedLoops + t).
Declaration
public static Vector2 Vector2Incremental(Vector2 from, Vector2 change, float t, int completedLoops)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | from | The original start vector at the beginning of the very first loop iteration. |
| Vector2 | change | The per-iteration delta vector (end minus start from the tween configuration). |
| float | t | The normalized time within the current loop iteration. May be outside |
| int | completedLoops | The number of loop iterations that have fully completed before the current one. Sourced from CompletedLoops. |
Returns
| Type | Description |
|---|---|
| Vector2 | The accumulated Vector2 value for the current frame. |
Vector3(Vector3, Vector3, float)
Interpolates between two UnityEngine.Vector3 values component-wise
using unclamped linear arithmetic. Each component is computed independently as
from.n + (to.n - from.n) * t, preserving any overshoot from the easing
function in all three axes.
Declaration
public static Vector3 Vector3(Vector3 from, Vector3 to, float t)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | from | The vector at |
| Vector3 | to | The vector at |
| float | t | The interpolation factor produced by the easing function.
May be outside |
Returns
| Type | Description |
|---|---|
| Vector3 | The component-wise interpolated vector. Individual components may exceed the range
|
Vector3Incremental(Vector3, Vector3, float, int)
Interpolates a UnityEngine.Vector3 value in
Incremental mode. Accumulates a constant
change vector per completed loop iteration. Each component
uses the formula from.n + change.n * (completedLoops + t).
Declaration
public static Vector3 Vector3Incremental(Vector3 from, Vector3 change, float t, int completedLoops)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | from | The original start vector at the beginning of the very first loop iteration. |
| Vector3 | change | The per-iteration delta vector (end minus start from the tween configuration). |
| float | t | The normalized time within the current loop iteration. May be outside |
| int | completedLoops | The number of loop iterations that have fully completed before the current one. Sourced from CompletedLoops. |
Returns
| Type | Description |
|---|---|
| Vector3 | The accumulated Vector3 value for the current frame. |
Vector4(Vector4, Vector4, float)
Interpolates between two UnityEngine.Vector4 values component-wise
using unclamped linear arithmetic. Each of the four components is computed
independently as from.n + (to.n - from.n) * t.
Declaration
public static Vector4 Vector4(Vector4 from, Vector4 to, float t)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector4 | from | The vector at |
| Vector4 | to | The vector at |
| float | t | The interpolation factor produced by the easing function.
May be outside |
Returns
| Type | Description |
|---|---|
| Vector4 | The component-wise interpolated vector. Individual components may exceed the range
|
Vector4Incremental(Vector4, Vector4, float, int)
Interpolates a UnityEngine.Vector4 value in
Incremental mode. Accumulates a constant
change vector per completed loop iteration across all four
components. Each component uses the formula from.n + change.n * (completedLoops + t).
Declaration
public static Vector4 Vector4Incremental(Vector4 from, Vector4 change, float t, int completedLoops)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector4 | from | The original start vector at the beginning of the very first loop iteration. |
| Vector4 | change | The per-iteration delta vector (end minus start from the tween configuration). |
| float | t | The normalized time within the current loop iteration. May be outside |
| int | completedLoops | The number of loop iterations that have fully completed before the current one. Sourced from CompletedLoops. |
Returns
| Type | Description |
|---|---|
| Vector4 | The accumulated Vector4 value for the current frame. |