Easing System
The template includes an Easing System that allows you to animate Transforms, RectTransforms, Images, and other components using a variety of easing functions. Animations are driven by coroutines and can be chained or yielded for sequential effects.
Easing Coroutine Methods
Each easing animation returns an IEasingCoroutine, which supports the following configuration methods:
// Sets one of the built-in easing functions.
// Default easing is Linear.
IEasingCoroutine SetEasing(EasingType easingType);
// Uses a custom AnimationCurve instead of an easing function.
// X-axis: time (0 -> 1)
// Y-axis: normalized progress (0 = start, 1 = end)
// Values outside 0-1 can create overshoot/bounce effects.
IEasingCoroutine SetEasingCurve(AnimationCurve easingCurve);
// Called when the easing animation completes.
IEasingCoroutine SetOnFinish(UnityAction action);
// If true, uses Time.unscaledDeltaTime instead of deltaTime.
// Default is false.
IEasingCoroutine SetUnscaledTime(bool unscaledTime);
// Adds a delay (in seconds) before the easing starts.
// Must be set before the coroutine begins.
IEasingCoroutine SetDelay(float delay);Extension Methods
Transform Extensions
DoPositionDoRotationDoLocalEulerAngles
RectTransform Extensions
DoAnchorPositionDoStretchedOffsetDoSizeDelta
Other Components
Additional utility extensions exist for animating UI and other component values.
Easing Manager Utility Methods
The Easing Manager also provides standalone coroutine helpers:
DoFloat - lerps a float value from start to end
DoAfter - executes an action after a delay or after a condition is met
DoNextFrame - runs an action on the next frame
DoNextFixedFrame - runs an action on the next physics frame
DoRepeatedly - calls an action repeatedly at a given interval for a duration
DoTimeScale - animates
Time.timeScaleStartCustomCoroutine - allows non-MonoBehaviour classes to start coroutines
All of these methods integrate seamlessly with Unity coroutines.
Example
This coroutine moves a transform forward for 1 second, then right for another second.
Both movements use the SineInOut easing function:
Scene Requirements
To use the Easing System, an Easing Manager component must exist in the active scene.
Important:
The Easing Manager must not be placed under DontDestroyOnLoad.
The system relies on easing coroutines stopping automatically when scenes unload.
Making the manager persistent will cause various issues.
Stopping Easing Coroutines
To stop an easing animation early, use:
Or safely stop it only if it exists:
StopIfExists is an extension method and avoids exceptions when the coroutine has not been initialized.
Last updated