Table of Contents

Class TweenExtensions

Namespace
Fallencake.UI
Assembly
Fallencake.UI.dll

Collection of coroutine-based tween helpers for common UI and transform animations.

public static class TweenExtensions
Inheritance
object
TweenExtensions

Methods

FadeCanvasGroup(CanvasGroup, float, float, AnimationCurve, bool, bool, float, Action, Action)

Fades a UnityEngine.CanvasGroup with interactivity and instant flags, supporting per-frame update.

public static IEnumerator FadeCanvasGroup(this CanvasGroup canvasGroup, float endAlpha, float duration, AnimationCurve ease, bool isInteractable, bool isInstantly, float delay = 0, Action onComplete = null, Action onUpdate = null)

Parameters

canvasGroup CanvasGroup
endAlpha float
duration float
ease AnimationCurve
isInteractable bool
isInstantly bool
delay float
onComplete Action
onUpdate Action

Returns

IEnumerator

FadeCanvasGroup(CanvasGroup, float, float, AnimationCurve, float, Action)

Fades a UnityEngine.CanvasGroup to endAlpha.

public static IEnumerator FadeCanvasGroup(this CanvasGroup canvasGroup, float endAlpha, float duration, AnimationCurve ease, float delay = 0, Action onComplete = null)

Parameters

canvasGroup CanvasGroup
endAlpha float
duration float
ease AnimationCurve
delay float
onComplete Action

Returns

IEnumerator

FadeCanvasGroupInstantly(CanvasGroup, float, bool, Action)

Sets a UnityEngine.CanvasGroup alpha immediately and optionnaly toggles interactivity.

public static void FadeCanvasGroupInstantly(this CanvasGroup canvasGroup, float endAlpha, bool isInteractable, Action onComplete = null)

Parameters

canvasGroup CanvasGroup
endAlpha float
isInteractable bool
onComplete Action

FadeGraphic(Graphic, float, float, float, AnimationCurve, float, Action, Action)

Animates Graphic alpha channel from specific start alpha to end alpha while keeping the color the same

public static IEnumerator FadeGraphic(this Graphic target, float startAlpha, float endAlpha, float duration, AnimationCurve ease, float delay = 0, Action onComplete = null, Action onUpdate = null)

Parameters

target Graphic

Target Graphic to animate

startAlpha float

Start alpha value (0-1)

endAlpha float

Target alpha value (0-1)

duration float

Animation duration

ease AnimationCurve

Animation curve

delay float

Delay before starting animation

onComplete Action

Callback when animation completes

onUpdate Action

Callback called every frame during animation

Returns

IEnumerator

FadeGraphic(Graphic, float, float, AnimationCurve, float, Action)

Fades a UnityEngine.UI.Graphic alpha to endAlpha.

public static IEnumerator FadeGraphic(this Graphic target, float endAlpha, float duration, AnimationCurve ease, float delay = 0, Action onComplete = null)

Parameters

target Graphic
endAlpha float
duration float
ease AnimationCurve
delay float
onComplete Action

Returns

IEnumerator

FadeGraphic(Graphic, float, float, AnimationCurve, float, Action, Action)

Animates Graphic alpha channel smoothly while keeping the color the same

public static IEnumerator FadeGraphic(this Graphic target, float endAlpha, float duration, AnimationCurve ease, float delay = 0, Action onComplete = null, Action onUpdate = null)

Parameters

target Graphic

Target Graphic to animate

endAlpha float

Target alpha value (0-1)

duration float

Animation duration

ease AnimationCurve

Animation curve

delay float

Delay before starting animation

onComplete Action

Callback when animation completes

onUpdate Action

Callback called every frame during animation

Returns

IEnumerator

FadeImage(Image, float, float, AnimationCurve, float, Action)

Fades an UnityEngine.UI.Image alpha to endAlpha.

public static IEnumerator FadeImage(this Image image, float endAlpha, float duration, AnimationCurve ease, float delay = 0, Action onComplete = null)

Parameters

image Image
endAlpha float
duration float
ease AnimationCurve
delay float
onComplete Action

Returns

IEnumerator

MoveRectTransform(RectTransform, Vector3, float, AnimationCurve, float, Action, Action)

Moves a UnityEngine.RectTransform.anchoredPosition to endPosition.

public static IEnumerator MoveRectTransform(this RectTransform transform, Vector3 endPosition, float duration, AnimationCurve ease, float delay = 0, Action onComplete = null, Action onUpdate = null)

Parameters

transform RectTransform
endPosition Vector3
duration float
ease AnimationCurve
delay float
onComplete Action
onUpdate Action

Returns

IEnumerator

MoveTransform(Transform, Vector3, float, AnimationCurve, bool, float, Action)

Moves a transform from its current position to endPosition.

public static IEnumerator MoveTransform(this Transform target, Vector3 endPosition, float duration, AnimationCurve ease, bool isLocalMovement = false, float delay = 0, Action onComplete = null)

Parameters

target Transform
endPosition Vector3
duration float
ease AnimationCurve
isLocalMovement bool
delay float
onComplete Action

Returns

IEnumerator

MoveTransform(Transform, Vector3, Vector3, float, AnimationCurve, bool, float, Action)

Animates Transform position from specific start position to end position

public static IEnumerator MoveTransform(this Transform target, Vector3 startPosition, Vector3 endPosition, float duration, AnimationCurve ease, bool isLocalMovement = false, float delay = 0, Action onComplete = null)

Parameters

target Transform

Target Transform to animate

startPosition Vector3

Start position value

endPosition Vector3

Target position value

duration float

Animation duration

ease AnimationCurve

Animation curve

isLocalMovement bool

Whether to use local position or world position

delay float

Delay before starting animation

onComplete Action

Callback when animation completes

Returns

IEnumerator

OffsetRectTransform(RectTransform, OffsetValues, float, AnimationCurve, float, Action, Action)

Animates RectTransform offsetMin and offsetMax values smoothly

public static IEnumerator OffsetRectTransform(this RectTransform target, OffsetValues endOffsetValues, float duration, AnimationCurve ease, float delay = 0, Action onComplete = null, Action onUpdate = null)

Parameters

target RectTransform

Target RectTransform to animate

endOffsetValues OffsetValues

Target offset values

duration float

Animation duration

ease AnimationCurve

Animation curve

delay float

Delay before starting animation

onComplete Action

Callback when animation completes

onUpdate Action

Returns

IEnumerator

RotateTransform(Transform, Vector3, float, AnimationCurve, float, Action)

Rotates a transform to endRotation (Euler angles).

public static IEnumerator RotateTransform(this Transform target, Vector3 endRotation, float duration, AnimationCurve ease, float delay = 0, Action onComplete = null)

Parameters

target Transform
endRotation Vector3
duration float
ease AnimationCurve
delay float
onComplete Action

Returns

IEnumerator

RotateTransform(Transform, Vector3, Vector3, float, AnimationCurve, float, Action)

Animates Transform rotation from specific start rotation to end rotation

public static IEnumerator RotateTransform(this Transform target, Vector3 startRotation, Vector3 endRotation, float duration, AnimationCurve ease, float delay = 0, Action onComplete = null)

Parameters

target Transform

Target Transform to animate

startRotation Vector3

Start rotation value (euler angles)

endRotation Vector3

Target rotation value (euler angles)

duration float

Animation duration

ease AnimationCurve

Animation curve

delay float

Delay before starting animation

onComplete Action

Callback when animation completes

Returns

IEnumerator

ScaleTransform(Transform, Vector3, float, AnimationCurve, float, Action, Action)

Scales a transform to endScale.

public static IEnumerator ScaleTransform(this Transform target, Vector3 endScale, float duration, AnimationCurve ease, float delay = 0, Action onComplete = null, Action onUpdate = null)

Parameters

target Transform
endScale Vector3
duration float
ease AnimationCurve
delay float
onComplete Action
onUpdate Action

Returns

IEnumerator

ScaleTransform(Transform, Vector3, Vector3, float, AnimationCurve, float, Action, Action)

Animates Transform scale from specific start scale to end scale

public static IEnumerator ScaleTransform(this Transform target, Vector3 startScale, Vector3 endScale, float duration, AnimationCurve ease, float delay = 0, Action onComplete = null, Action onUpdate = null)

Parameters

target Transform

Target Transform to animate

startScale Vector3

Start scale value

endScale Vector3

Target scale value

duration float

Animation duration

ease AnimationCurve

Animation curve

delay float

Delay before starting animation

onComplete Action

Callback when animation completes

onUpdate Action

Callback called every frame during animation

Returns

IEnumerator

ScaleTransformInstantly(Transform, Vector3, Action)

Sets a transform scale immediately.

public static void ScaleTransformInstantly(this Transform target, Vector3 endScale, Action onComplete = null)

Parameters

target Transform
endScale Vector3
onComplete Action

SizeRectTransform(RectTransform, Vector2, float, AnimationCurve, float, Action, Action)

Animates RectTransform sizeDelta values smoothly

public static IEnumerator SizeRectTransform(this RectTransform target, Vector2 endSize, float duration, AnimationCurve ease, float delay = 0, Action onComplete = null, Action onUpdate = null)

Parameters

target RectTransform

Target RectTransform to animate

endSize Vector2

Target size values

duration float

Animation duration

ease AnimationCurve

Animation curve

delay float

Delay before starting animation

onComplete Action

Callback when animation completes

onUpdate Action

Returns

IEnumerator

SwapObjects(RectTransform, RectTransform, CanvasGroup, CanvasGroup, Vector2, float, AnimationCurve, Action)

Swaps two objects by moving their positions and cross-fading their UnityEngine.CanvasGroup alphas.

public static IEnumerator SwapObjects(RectTransform currentTransform, RectTransform previousTransform, CanvasGroup currentCanvasGroup, CanvasGroup previousCanvasGroup, Vector2 endPosition, float duration, AnimationCurve ease, Action onComplete = null)

Parameters

currentTransform RectTransform

Transform to move in.

previousTransform RectTransform

Transform to move out.

currentCanvasGroup CanvasGroup

CanvasGroup to fade in.

previousCanvasGroup CanvasGroup

CanvasGroup to fade out.

endPosition Vector2

Delta position to move each transform.

duration float

Animation duration in seconds.

ease AnimationCurve

Easing curve.

onComplete Action

Callback after finishing.

Returns

IEnumerator

SwitchToggleHandle(RectTransform, bool, bool, float, AnimationCurve, Graphic, Color, Image, Color, CanvasGroup, CanvasGroup, float, float)

public static IEnumerator SwitchToggleHandle(RectTransform handle, bool isOn, bool isStretchingHandle, float duration, AnimationCurve ease, Graphic handleGraphic, Color handleEndColor, Image backgroundImage, Color backgroundEndColor, CanvasGroup handleOverlap = null, CanvasGroup backgroundOverlap = null, float stretchScaleX = 1, float stretchScaleY = 1)

Parameters

handle RectTransform
isOn bool
isStretchingHandle bool
duration float
ease AnimationCurve
handleGraphic Graphic
handleEndColor Color
backgroundImage Image
backgroundEndColor Color
handleOverlap CanvasGroup
backgroundOverlap CanvasGroup
stretchScaleX float
stretchScaleY float

Returns

IEnumerator

SwitchToggleHandleAxis(RectTransform, bool, bool, float, AnimationCurve, Graphic, Color, Image, Color, IList<ToggleGraphic>, CanvasGroup, CanvasGroup, float, float, SwitchDirection)

Switches a toggle handle with optional stretching, color/alpha overlays and axis selection.

public static IEnumerator SwitchToggleHandleAxis(RectTransform handle, bool isOn, bool isStretchingHandle, float duration, AnimationCurve ease, Graphic handleGraphic, Color handleEndColor, Image backgroundImage, Color backgroundEndColor, IList<ToggleGraphic> colorTargets, CanvasGroup handleOverlap = null, CanvasGroup backgroundOverlap = null, float stretchScaleX = 1, float stretchScaleY = 1, SwitchDirection switchDirection = SwitchDirection.Horizontal)

Parameters

handle RectTransform
isOn bool
isStretchingHandle bool
duration float
ease AnimationCurve
handleGraphic Graphic
handleEndColor Color
backgroundImage Image
backgroundEndColor Color
colorTargets IList<ToggleGraphic>
handleOverlap CanvasGroup
backgroundOverlap CanvasGroup
stretchScaleX float
stretchScaleY float
switchDirection SwitchDirection

Returns

IEnumerator

SwitchToggleHandleAxisExtended(RectTransform, bool, bool, float, AnimationCurve, Graphic, Color, Image, Color, IList<ToggleGraphic>, CanvasGroup, CanvasGroup, float, float, SwitchDirection)

Extended API: explicit method name that supports a list of color targets. Keeps older code calling SwitchToggleHandleAxis intact, while new code may call this name for clarity.

public static IEnumerator SwitchToggleHandleAxisExtended(RectTransform handle, bool isOn, bool isStretchingHandle, float duration, AnimationCurve ease, Graphic handleGraphic, Color handleEndColor, Image backgroundImage, Color backgroundEndColor, IList<ToggleGraphic> colorTargets, CanvasGroup handleOverlap = null, CanvasGroup backgroundOverlap = null, float stretchScaleX = 1, float stretchScaleY = 1, SwitchDirection switchDirection = SwitchDirection.Horizontal)

Parameters

handle RectTransform
isOn bool
isStretchingHandle bool
duration float
ease AnimationCurve
handleGraphic Graphic
handleEndColor Color
backgroundImage Image
backgroundEndColor Color
colorTargets IList<ToggleGraphic>
handleOverlap CanvasGroup
backgroundOverlap CanvasGroup
stretchScaleX float
stretchScaleY float
switchDirection SwitchDirection

Returns

IEnumerator

TintGraphic(Transform, Color, float, AnimationCurve, float, Action)

Convenience: finds a UnityEngine.UI.Graphic on the transform and tints it.

public static IEnumerator TintGraphic(this Transform transform, Color endColor, float duration, AnimationCurve ease, float delay = 0, Action onComplete = null)

Parameters

transform Transform
endColor Color
duration float
ease AnimationCurve
delay float
onComplete Action

Returns

IEnumerator

TintGraphic(Graphic, Color, float, AnimationCurve, float, Action)

Tints a UnityEngine.UI.Graphic color to endColor.

public static IEnumerator TintGraphic(this Graphic target, Color endColor, float duration, AnimationCurve ease, float delay = 0, Action onComplete = null)

Parameters

target Graphic
endColor Color
duration float
ease AnimationCurve
delay float
onComplete Action

Returns

IEnumerator

TintGraphic(Graphic, Color, float, AnimationCurve, float, Action, Action)

Tints a UnityEngine.UI.Graphic color to endColor and invokes onUpdate per frame.

public static IEnumerator TintGraphic(this Graphic target, Color endColor, float duration, AnimationCurve ease, float delay = 0, Action onComplete = null, Action onUpdate = null)

Parameters

target Graphic
endColor Color
duration float
ease AnimationCurve
delay float
onComplete Action
onUpdate Action

Returns

IEnumerator