CurveTween 文档

功能列表

Fade(淡入淡出)

对对象的透明度(Alpha)进行动画处理。

• 支持的组件
• 使用示例

Move(移动)

对 Transform 的位置进行动画处理。

• 使用示例

Scale(缩放)

对 Transform 的缩放进行动画处理。

• 使用示例

Rotate(旋转)

对 Transform 的旋转进行动画处理。

• 使用示例

Color(颜色)

对颜色(Color)进行动画处理。

• 支持的组件
• 使用示例

Text(UI Text/TextMeshPro)

实现打字机风格的文字动画。

• 使用示例

RichText (TextMeshPro)

支持富文本、打字效果动画、旋转动画以及字体大小缩放动画。(需要注意的是,它的 GC 开销较高,可能会影响性能。)

• 使用示例

Light

对 Unity Light 组件的属性进行动画处理。

• 支持的属性
• 使用示例

FillAmount

用于为 Image 组件的 fillAmount 值制作动画的功能。 可用于血条、冷却时间、圆形加载等 UI 表现。

• 目标对象
• 使用示例

IntInterpolate / FloatInterpolate

用于在 Text / TextMeshPro 中对数值进行插值动画的功能。 适用于数字增长、伤害数字、分数动画等效果。

• 目标对象
• 使用示例

TMPMeshExplodeInAnimation

直接操作 TextMeshPro 顶点数据,使每个字符单独爆炸的动画。 可细致控制速度、方向、扩散度、随机性等,非常适合华丽的特效。

• 目标对象
• 使用示例
• 使用示例

TMPMeshRevealAnimation

直接操作 TextMeshPro 顶点,实现以下复杂的文字动画效果: 透明度(Fade)、字符缩放(Scale)、旋转(Rotate)、移动(Move)、波形变形(Wave)、弹跳变形(Bounce)。 从打字机效果到动态复杂的文字动画都能实现。

• 目标对象
• 使用示例
• 使用示例

PathCurveAnimation

沿由多个点组成的曲线(路径)移动目标对象。

• 使用示例

API 参考文档

DoCanvasFade

用于为 CanvasGroup 的 alpha 值播放动画的实用方法。

ITweenPlayer DoCanvasFade(this GameObject target, float forwardValue = 0, bool blocksraycasts = false, float duration = 1);

ITweenPlayer DoCanvasFade(this GameObject target, AnimationCurve curve, float forwardValue = 0, bool blocksraycasts = false);

ITweenPlayer DoCanvasFade(this MonoBehaviour target, float forwardValue = 0, bool blocksraycasts = false, float duration = 1);

ITweenPlayer DoCanvasFade(this MonoBehaviour target, AnimationCurve curve, float forwardValue = 0, bool blocksraycasts = false);

ITweenPlayer DoCanvasFade(this CanvasGroup target, float forwardValue = 0, bool blocksraycasts = false, float duration = 1);

ITweenPlayer DoCanvasFade(this CanvasGroup target, AnimationCurve curve, float forwardValue = 0, bool blocksraycasts = false);

• 参数

DoFade

用于为目标对象的 alpha 值播放动画的实用方法。

ITweenPlayer DoFade(this Material target, float forwardValue = 0, float duration = 1);

ITweenPlayer DoFade(this Renderer target, float forwardValue = 0, float duration = 1);

ITweenPlayer DoFade(this Graphic target, float forwardValue = 0, float duration = 1);

ITweenPlayer DoFade(this Renderer target, AnimationCurve curve, float forwardValue = 0);

ITweenPlayer DoFade(this Graphic target, AnimationCurve curve, float forwardValue = 0);

ITweenPlayer DoFade(this Material target, AnimationCurve curve, float forwardValue = 0);

• 参数

DoColor

用于为目标对象的 Color 播放动画的实用方法。

ITweenPlayer DoColor(this Graphic target, Color forwardValue, float duration = 1);

ITweenPlayer DoColor(this Graphic target, Color forwardValue, AnimationCurve curve);

ITweenPlayer DoColor(this Renderer target, Color forwardValue, float duration = 1);

ITweenPlayer DoColor(this Renderer target, Color forwardValue, AnimationCurve curve);

ITweenPlayer DoColor(this Material target, Color forwardValue, float duration = 1);

ITweenPlayer DoColor(this Material target, Color forwardValue, AnimationCurve curve);

• 参数

DoFillAmount

DoFillAmount 是一个扩展方法,用于平滑地为 UnityEngine.UI.Image 的 fillAmount 播放动画。

ITweenPlayer DoFillAmount(this Image target, float forwardValue = 0, float duration = 1);

ITweenPlayer DoFillAmount(this Image target, AnimationCurve curve, float forwardValue = 0);

• 参数

DoLight / DoIntensity / DoRange

用于为 Light 组件的 color、intensity、range 播放动画的实用方法。

ITweenPlayer DoColor(this Light target, Color color, float duration = 1);

ITweenPlayer DoColor(this Light target, Color color, AnimationCurve curve);

ITweenPlayer DoIntensity(this Light target, float intensity, float duration = 1);

ITweenPlayer DoIntensity(this Light target, float intensity, AnimationCurve curve);

ITweenPlayer DoRange(this Light target, float range, float duration = 1);

ITweenPlayer DoRange(this Light target, float range, AnimationCurve curve);

ITweenPlayer DoLight(this Light target, bool colortween = false, Color color = default, bool intensitytween = false, float intensity = 0, bool rangetween = false, float range = 0, float duration = 1);

ITweenPlayer DoLight(this Light target, AnimationCurve curve, bool colortween = false, Color color = default, bool intensitytween = false, float intensity = 0, bool rangetween = false, float range = 0);

• 参数

DoInterpolate

用于在 Text / TextMeshPro 中以插值方式播放数值动画的实用方法。

ITweenPlayer DoInterpolate(this Text target, int forwardValue, float duration = 1);

ITweenPlayer DoInterpolate(this Text target, int forwardValue, AnimationCurve curve);

ITweenPlayer DoInterpolate(this Text target, float forwardValue, float duration = 1);

ITweenPlayer DoInterpolate(this Text target, float forwardValue, AnimationCurve curve);

ITweenPlayer DoInterpolate(this TMP_Text target, float forwardValue, float duration = 1);

ITweenPlayer DoInterpolate(this TMP_Text target, float forwardValue, AnimationCurve curve);

ITweenPlayer DoInterpolate(this TMP_Text target, int forwardValue, float duration = 1);

ITweenPlayer DoInterpolate(this TMP_Text target, int forwardValue, AnimationCurve curve);

• 参数

DoMove / DoMove(X/Y/Z)

用于为目标对象的移动播放动画的实用方法。

ITweenPlayer DoMoveX(this GameObject target, float x, float duration = 1);

ITweenPlayer DoMoveX(this GameObject target, float x, AnimationCurve curve);

ITweenPlayer DoMoveY(this GameObject target, float y, float duration = 1);

ITweenPlayer DoMoveY(this GameObject target, float y, AnimationCurve curve);

ITweenPlayer DoMoveZ(this GameObject target, float z, float duration = 1);

ITweenPlayer DoMoveZ(this GameObject target, float z, AnimationCurve curve);

ITweenPlayer DoMove(this GameObject target, Vector3 forwardValue, float duration = 1, bool relative = false);

ITweenPlayer DoMove(this GameObject target, Vector3 forwardValue, AnimationCurve curve, bool relative = false);

ITweenPlayer DoMoveX<T>(this T target, float x, float duration = 1) where T : Component;

ITweenPlayer DoMoveX<T>(this T target, float x, AnimationCurve curve) where T : Component;

ITweenPlayer DoMoveY<T>(this T target, float y, float duration = 1) where T : Component;

ITweenPlayer DoMoveY<T>(this T target, float y, AnimationCurve curve) where T : Component;

ITweenPlayer DoMoveZ<T>(this T target, float z, float duration = 1) where T : Component;

ITweenPlayer DoMoveZ<T>(this T target, float z, AnimationCurve curve) where T : Component;

ITweenPlayer DoMove<T>(this T target, Vector3 forwardValue, float duration = 1, bool relative = false) where T : Component;

ITweenPlayer DoMove<T>(this T target, Vector3 forwardValue, AnimationCurve curve, bool relative = false) where T : Component;

• 参数

DoRotation / DoRotation(X/Y/Z)

用于为目标对象的旋转播放动画的实用方法。

ITweenPlayer DoRotationX(this GameObject target, float x, float duration = 1);

ITweenPlayer DoRotationX(this GameObject target, float x, AnimationCurve curve);

ITweenPlayer DoRotationY(this GameObject target, float y, float duration = 1);

ITweenPlayer DoRotationY(this GameObject target, float y, AnimationCurve curve);

ITweenPlayer DoRotationZ(this GameObject target, float z, float duration = 1);

ITweenPlayer DoRotationZ(this GameObject target, float z, AnimationCurve curve);

ITweenPlayer DoRotation(this GameObject target, Vector3 forwardValue, float duration = 1, bool relative = false);

ITweenPlayer DoRotation(this GameObject target, Vector3 forwardValue, AnimationCurve curve, bool relative = false);

ITweenPlayer DoRotationX<T>(this T target, float x, float duration = 1) where T : Component;

ITweenPlayer DoRotationX<T>(this T target, float x, AnimationCurve curve) where T : Component;

ITweenPlayer DoRotationY<T>(this T target, float y, float duration = 1) where T : Component;

ITweenPlayer DoRotationY<T>(this T target, float y, AnimationCurve curve) where T : Component;

ITweenPlayer DoRotationZ<T>(this T target, float z, float duration = 1) where T : Component;

ITweenPlayer DoRotationZ<T>(this T target, float z, AnimationCurve curve) where T : Component;

ITweenPlayer DoRotation<T>(this T target, Vector3 forwardValue, float duration = 1, bool relative = false) where T : Component;

ITweenPlayer DoRotation<T>(this T target, Vector3 forwardValue, AnimationCurve curve, bool relative = false) where T : Component;

• 参数

DoScale / DoScale(X/Y/Z)

用于为目标对象的缩放播放动画的实用方法。

ITweenPlayer DoScaleX(this GameObject target, float x, float duration = 1);

ITweenPlayer DoScaleX(this GameObject target, float x, AnimationCurve curve);

ITweenPlayer DoScaleY(this GameObject target, float y, float duration = 1);

ITweenPlayer DoScaleY(this GameObject target, float y, AnimationCurve curve);

ITweenPlayer DoScaleZ(this GameObject target, float z, float duration = 1);

ITweenPlayer DoScaleZ(this GameObject target, float z, AnimationCurve curve);

ITweenPlayer DoScale(this GameObject target, Vector3 forwardValue, float duration = 1, bool relative = false);

ITweenPlayer DoScale(this GameObject target, Vector3 forwardValue, AnimationCurve curve, bool relative = false);

ITweenPlayer DoScaleX<T>(this T target, float x, float duration = 1) where T : Component;

ITweenPlayer DoScaleX<T>(this T target, float x, AnimationCurve curve) where T : Component;

ITweenPlayer DoScaleY<T>(this T target, float y, float duration = 1) where T : Component;

ITweenPlayer DoScaleY<T>(this T target, float y, AnimationCurve curve) where T : Component;

ITweenPlayer DoScaleZ<T>(this T target, float z, float duration = 1) where T : Component;

ITweenPlayer DoScaleZ<T>(this T target, float z, AnimationCurve curve) where T : Component;

ITweenPlayer DoScale<T>(this T target, Vector3 forwardValue, float duration = 1, bool relative = false) where T : Component;

ITweenPlayer DoScale<T>(this T target, Vector3 forwardValue, AnimationCurve curve, bool relative = false) where T : Component;

• 参数

DoReveal

用于以打字机风格逐字显示文本的实用方法。

ITweenPlayer DoReveal(this Text target, string text = null, float duration = 1);

ITweenPlayer DoReveal(this Text target, AnimationCurve curve, string text = null);

ITweenPlayer DoReveal(this TMP_Text target, string text = null, float duration = 1);

ITweenPlayer DoReveal(this TMP_Text target, AnimationCurve curve, string text = null);

• 参数

DoRichTextReveal

支持富文本的打字机风动画的实用方法

IRichTextPlayer DoRichTextReveal(this TMP_Text target, string text = null, float duration = 1);

IRichTextPlayer DoRichTextReveal(this TMP_Text target, AnimationCurve curve, string text = null);

• 参数

DoRichTextRotateTween

支持富文本,并对 TextMeshPro 的字符执行旋转动画。

IRichTextPlayer DoRichTextRotateTween(this TMP_Text target, float rotate, string text = null, float duration = 1);

IRichTextPlayer DoRichTextRotateTween(this TMP_Text target, AnimationCurve curve, float rotate, string text = null);

• 参数

DoRichTextSizeTween

用于以动画方式改变 TextMeshPro 的字体大小。

IRichTextPlayer DoRichTextSizeTween(this TMP_Text target, float fontsize, string text = null, float duration = 1);

IRichTextPlayer DoRichTextSizeTween(this TMP_Text target, AnimationCurve curve, float fontsize, string text = null);

• 参数

DoRichTextTween

支持富文本,可同时执行打字机动画、旋转、字体大小变化的复合文本动画功能。

IRichTextPlayer DoRichTextTween(this TMP_Text target, bool reveal = true, string text = null, bool sizetween = false, float fontsize = 0, bool rotatetween = false, float rotate = 0, float duration = 1);

IRichTextPlayer DoRichTextTween(this TMP_Text target, AnimationCurve curve, bool reveal = true, string text = null, bool sizetween = false, float fontsize = 0, bool rotatetween = false, float rotate = 0);

• 参数

DoMeshExplodeIn

一个直接操作 TextMeshPro 顶点数据的实用方法,用于生成让每个字符独立向外“爆炸”飞散的动画。

IExplodeInPlayer DoMeshExplodeIn(this TMP_Text target, string text = null, float explosionPower = 200, bool fadeOut = true, float fadedelay = 0, bool rotate = true, float rotateMin = 50, float rotateMax = 500, bool useFloatiness = true, float factorMin = 0.02F, float factorMax = 0.15F, float duration = 1);

IExplodeInPlayer DoMeshExplodeIn(this TMP_Text target, AnimationCurve curve, string text = null, float explosionPower = 200, bool fadeOut = true, float fadedelay = 0, bool rotate = true, float rotateMin = 50, float rotateMax = 500, bool useFloatiness = true, float factorMin = 0.02F, float factorMax = 0.15F);

• 参数

DoMeshExplodeInFadeOut

一个直接操作 TextMeshPro 顶点数据的实用方法,使字符作为独立网格爆炸飞散并同时淡出。

IExplodeInPlayer DoMeshExplodeInFadeOut(this TMP_Text target, string text = null, float explosionPower = 200, float delay = 0, float duration = 1);

IExplodeInPlayer DoMeshExplodeInFadeOut(this TMP_Text target, AnimationCurve curve, string text = null, float explosionPower = 200, float delay = 0);

• 参数

DoMeshExplodeInFloatinessFadeOut

一个直接操作 TextMeshPro 顶点数据的实用方法,使字符在漂浮摆动的同时向四周飞散,并同步淡出。

IExplodeInPlayer DoMeshExplodeInFloatinessFadeOut(this TMP_Text target, string text = null, float explosionPower = 200, float fadedelay = 0, float factorMin = 0.02F, float factorMax = 0.15F, float duration = 1);

IExplodeInPlayer DoMeshExplodeInFloatinessFadeOut(this TMP_Text target, AnimationCurve curve, string text = null, float explosionPower = 200, float fadedelay = 0, float factorMin = 0.02F, float factorMax = 0.15F);

• 参数

DoMeshExplodeInRotateFadeOut

一个直接操作 TextMeshPro 顶点数据的实用方法,可让文字在独立旋转的同时爆炸式飞散并淡出。

IExplodeInPlayer DoMeshExplodeInRotateFadeOut(this TMP_Text target, string text = null, float explosionPower = 200, float fadedelay = 0, float rotateMin = 50, float rotateMax = 500, float duration = 1);

IExplodeInPlayer DoMeshExplodeInRotateFadeOut(this TMP_Text target, AnimationCurve curve, string text = null, float explosionPower = 200, float fadedelay = 0, float rotateMin = 50, float rotateMax = 500);

• 参数

DoMeshReveal

一个直接操作 TextMeshPro 顶点的实用方法,可实现 Fade / Scale / Move / Rotate / Wave / Bounce 等多种复合文字动画效果。

IRevealPlayer DoMeshReveal(this TMP_Text target, bool reveal = true, string text = null, bool fadetween = false, float alpha = 1, bool postween = false, Vector3 distance = default, bool scaletween = false, float scale = 1, bool rotatetween = false, Vector3 rotate = default, WaveType wavetype = WaveType.None, float frequency = 0, float duration = 1);

IRevealPlayer DoMeshReveal(this TMP_Text target, AnimationCurve curve, bool reveal = true, string text = null, bool fadetween = false, float alpha = 1, bool postween = false, Vector3 distance = default, bool scaletween = false, float scale = 1, bool rotatetween = false, Vector3 rotate = default, WaveType wavetype = WaveType.None, float frequency = 0);

• 参数

DoMeshFadeReveal

一个直接操作 TextMeshPro 顶点、以 Fade + Reveal 为核心实现复合文字效果的实用方法。

IRevealPlayer DoMeshFadeReveal(this TMP_Text target, float alpha = 0, bool reveal = true, string text = null, float duration = 1);

IRevealPlayer DoMeshFadeReveal(this TMP_Text target, AnimationCurve curve, float alpha = 0, bool reveal = true, string text = null);

• 参数

DoMeshMoveReveal / DoMeshMove(X/Y/Z)Reveal

用于直接操作 TextMeshPro 顶点的实用方法,可实现以 Move(位移)+ Reveal 为核心,并可组合 Wave / Bounce 等效果的动画。

IRevealPlayer DoMeshMoveReveal(this TMP_Text target, Vector3 distance, WaveType wavetype = WaveType.None, float frequency = 0, bool reveal = true, string text = null, float duration = 1);

IRevealPlayer DoMeshMoveReveal(this TMP_Text target, Vector3 distance, AnimationCurve curve, WaveType wavetype = WaveType.None, float frequency = 0, bool reveal = true, string text = null);

IRevealPlayer DoMeshMoveXReveal(this TMP_Text target, float x, WaveType wavetype = WaveType.None, float frequency = 0, bool reveal = true, string text = null, float duration = 1);

IRevealPlayer DoMeshMoveXReveal(this TMP_Text target, float x, AnimationCurve curve, WaveType wavetype = WaveType.None, float frequency = 0, bool reveal = true, string text = null);

IRevealPlayer DoMeshMoveYReveal(this TMP_Text target, float y, WaveType wavetype = WaveType.None, float frequency = 0, bool reveal = true, string text = null, float duration = 1);

IRevealPlayer DoMeshMoveYReveal(this TMP_Text target, float y, AnimationCurve curve, WaveType wavetype = WaveType.None, float frequency = 0, bool reveal = true, string text = null);

IRevealPlayer DoMeshMoveZReveal(this TMP_Text target, float z, WaveType wavetype = WaveType.None, float frequency = 0, bool reveal = true, string text = null, float duration = 1);

IRevealPlayer DoMeshMoveZReveal(this TMP_Text target, float z, AnimationCurve curve, WaveType wavetype = WaveType.None, float frequency = 0, bool reveal = true, string text = null);

• 参数

DoMeshRotateReveal / DoMeshRotate(X/Y/Z)Reveal

用于直接操作 TextMeshPro 顶点的实用方法,可实现以 Rotate(旋转)+ Reveal 为核心的动画。

IRevealPlayer DoMeshRotateReveal(this TMP_Text target, Vector3 rotate, bool reveal = true, string text = null, float duration = 1);

IRevealPlayer DoMeshRotateReveal(this TMP_Text target, Vector3 rotate, AnimationCurve curve, bool reveal = true, string text = null);

IRevealPlayer DoMeshRotateXReveal(this TMP_Text target, float x, bool reveal = true, string text = null, float duration = 1);

IRevealPlayer DoMeshRotateXReveal(this TMP_Text target, float x, AnimationCurve curve, bool reveal = true, string text = null);

IRevealPlayer DoMeshRotateYReveal(this TMP_Text target, float y, AnimationCurve curve, bool reveal = true, string text = null);

IRevealPlayer DoMeshRotateYReveal(this TMP_Text target, float y, bool reveal = true, string text = null, float duration = 1);

IRevealPlayer DoMeshRotateZReveal(this TMP_Text target, float z, bool reveal = true, string text = null, float duration = 1);

IRevealPlayer DoMeshRotateZReveal(this TMP_Text target, float z, AnimationCurve curve, bool reveal = true, string text = null);

• 参数

DoMeshScaleReveal

用于直接操作 TextMeshPro 顶点的实用方法,可实现以 Scale(缩放)+ Reveal 为核心的动画。

IRevealPlayer DoMeshScaleReveal(this TMP_Text target, AnimationCurve curve, float scale = 0, bool reveal = true, string text = null);

IRevealPlayer DoMeshScaleReveal(this TMP_Text target, float scale = 0, bool reveal = true, string text = null, float duration = 1);

• 参数

Path Settings

用于沿由多个点组成的曲线(路径)移动对象的动画功能。

IPathPlayer SetClosed(bool closed);

• 参数

IPathPlayer SetLookMode(PathLookMode lookmode);

• 参数

IPathPlayer SetPoints(List vectors);

IPathPlayer SetTarget(Transform target);

IPathPlayer SetUseLocalPosition(bool uselocal);

• 参数

IPathPlayer SnapTargetToFirstPoint();

CurveTween Settings

iTweenPlayer SetDelay(float delay);

iTweenPlayer SetDuration(float duration);

iTweenPlayer SetEase(EaseType easeType);

iTweenPlayer SetLoop(bool loop);

iTweenPlayer SetLoopCount(int loopCount);

ITweenPlayerSetLoopDelay(bool loopDelay);

iTweenPlayer SetLoopType(LoopType loopType);

• 参数

iTweenPlayer SetScaledTime(bool scaledtime);

iTweenPlayer SetYoYoDelay(float yoYoDelay);

iTweenPlayer SetValue(object value);

Play / Stop

void Play();

void Play(bool reversePlay);

• 参数

void PlayOnce();

void PlayReverseOnce();

void Stop();

void ForceEnd(bool invokeCallback);

• 参数

void StopAndReset();

Event Callbacks

iTweenPlayer AddOnStartListener(UnityAction call);

iTweenPlayer AddOnYoYoListener(UnityAction call);

iTweenPlayer AddOnCompleteListener(UnityAction call);

GetAnimationCurve

根据 EaseType 生成对应的动画曲线(Keyframe 数组),用于 Tween 插值处理。

Keyframe[] CurveTweenUtility.GetAnimationCurve(EaseType easeType);