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
-
objectTweenExtensions
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
canvasGroupCanvasGroupendAlphafloatdurationfloateaseAnimationCurveisInteractableboolisInstantlybooldelayfloatonCompleteActiononUpdateAction
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
canvasGroupCanvasGroupendAlphafloatdurationfloateaseAnimationCurvedelayfloatonCompleteAction
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
canvasGroupCanvasGroupendAlphafloatisInteractableboolonCompleteAction
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
targetGraphicTarget Graphic to animate
startAlphafloatStart alpha value (0-1)
endAlphafloatTarget alpha value (0-1)
durationfloatAnimation duration
easeAnimationCurveAnimation curve
delayfloatDelay before starting animation
onCompleteActionCallback when animation completes
onUpdateActionCallback 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
targetGraphicendAlphafloatdurationfloateaseAnimationCurvedelayfloatonCompleteAction
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
targetGraphicTarget Graphic to animate
endAlphafloatTarget alpha value (0-1)
durationfloatAnimation duration
easeAnimationCurveAnimation curve
delayfloatDelay before starting animation
onCompleteActionCallback when animation completes
onUpdateActionCallback 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
imageImageendAlphafloatdurationfloateaseAnimationCurvedelayfloatonCompleteAction
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
transformRectTransformendPositionVector3durationfloateaseAnimationCurvedelayfloatonCompleteActiononUpdateAction
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
targetTransformendPositionVector3durationfloateaseAnimationCurveisLocalMovementbooldelayfloatonCompleteAction
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
targetTransformTarget Transform to animate
startPositionVector3Start position value
endPositionVector3Target position value
durationfloatAnimation duration
easeAnimationCurveAnimation curve
isLocalMovementboolWhether to use local position or world position
delayfloatDelay before starting animation
onCompleteActionCallback 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
targetRectTransformTarget RectTransform to animate
endOffsetValuesOffsetValuesTarget offset values
durationfloatAnimation duration
easeAnimationCurveAnimation curve
delayfloatDelay before starting animation
onCompleteActionCallback when animation completes
onUpdateAction
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
targetTransformendRotationVector3durationfloateaseAnimationCurvedelayfloatonCompleteAction
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
targetTransformTarget Transform to animate
startRotationVector3Start rotation value (euler angles)
endRotationVector3Target rotation value (euler angles)
durationfloatAnimation duration
easeAnimationCurveAnimation curve
delayfloatDelay before starting animation
onCompleteActionCallback 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
targetTransformendScaleVector3durationfloateaseAnimationCurvedelayfloatonCompleteActiononUpdateAction
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
targetTransformTarget Transform to animate
startScaleVector3Start scale value
endScaleVector3Target scale value
durationfloatAnimation duration
easeAnimationCurveAnimation curve
delayfloatDelay before starting animation
onCompleteActionCallback when animation completes
onUpdateActionCallback 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
targetTransformendScaleVector3onCompleteAction
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
targetRectTransformTarget RectTransform to animate
endSizeVector2Target size values
durationfloatAnimation duration
easeAnimationCurveAnimation curve
delayfloatDelay before starting animation
onCompleteActionCallback when animation completes
onUpdateAction
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
currentTransformRectTransformTransform to move in.
previousTransformRectTransformTransform to move out.
currentCanvasGroupCanvasGroupCanvasGroup to fade in.
previousCanvasGroupCanvasGroupCanvasGroup to fade out.
endPositionVector2Delta position to move each transform.
durationfloatAnimation duration in seconds.
easeAnimationCurveEasing curve.
onCompleteActionCallback after finishing.
Returns
- IEnumerator
SwitchToggleHandle(RectTransform, bool, bool, float, AnimationCurve, Graphic, Color, Image, Color, CanvasGroup, CanvasGroup, float, float)
Backward-compatible wrapper of SwitchToggleHandleAxis(RectTransform, bool, bool, float, AnimationCurve, Graphic, Color, Image, Color, IList<ToggleGraphic>, CanvasGroup, CanvasGroup, float, float, SwitchDirection) for horizontal movement.
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
handleRectTransformisOnboolisStretchingHandlebooldurationfloateaseAnimationCurvehandleGraphicGraphichandleEndColorColorbackgroundImageImagebackgroundEndColorColorhandleOverlapCanvasGroupbackgroundOverlapCanvasGroupstretchScaleXfloatstretchScaleYfloat
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
handleRectTransformisOnboolisStretchingHandlebooldurationfloateaseAnimationCurvehandleGraphicGraphichandleEndColorColorbackgroundImageImagebackgroundEndColorColorcolorTargetsIList<ToggleGraphic>handleOverlapCanvasGroupbackgroundOverlapCanvasGroupstretchScaleXfloatstretchScaleYfloatswitchDirectionSwitchDirection
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
handleRectTransformisOnboolisStretchingHandlebooldurationfloateaseAnimationCurvehandleGraphicGraphichandleEndColorColorbackgroundImageImagebackgroundEndColorColorcolorTargetsIList<ToggleGraphic>handleOverlapCanvasGroupbackgroundOverlapCanvasGroupstretchScaleXfloatstretchScaleYfloatswitchDirectionSwitchDirection
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
transformTransformendColorColordurationfloateaseAnimationCurvedelayfloatonCompleteAction
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
targetGraphicendColorColordurationfloateaseAnimationCurvedelayfloatonCompleteAction
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
targetGraphicendColorColordurationfloateaseAnimationCurvedelayfloatonCompleteActiononUpdateAction
Returns
- IEnumerator