DOTween使用

  DoTween官网:[http://dotween.demigiant.com/pro.php](http://dotween.demigiant.com/pro.php)

常用API:

(基本控制回调)

 
组件实例.DOPlay() 播放动画
组件实例.DOPause() 暂停动画
组件实例.DOPlayForward() 正放动画
组件实例.DOPlayBackwards() 倒放动画,倒放不会循环
组件实例.DOKill() 杀死动画
tweener.SetLoops() 设置循环次数。-1:无限循环
tweener.SetEase() 设置缓动效果

 (生命周期↓)

 
tweener.OnStart() 动画开始时调用,不管循环多少次,只调用一次
tweener.OnUpdate() 动画播放时调用
tweener.OnPlay() 动画开始播放时调用
tweener.OnPause() 动画暂停时调用
tweener.OnKill() 动画完全结束时或者被杀死时调用
tweener.OnStepComplete() 单次动画结束时调用,因为我们设置了循环,这里时指单次动画结束
tweener.OnComplete() 动画完全结束时调用,在OnKill之前调用
tweener.OnWaypointChange() 当动画目标点被修改时调用
tweener.OnRewind() 倒放结束时调用
Sequence队列 就是将多个动画放到一个队列里面,然后挨个挨个播放,并可以循环。
DOTween.Sequence() 创建队列
sequence.Append(tweener) 将动画加入队列
sequence.Insert(1, tweener) 插入一个并行的动画到队列的某个位置
sequence.SetLoops(-1) 设置队列是否循环。-1:无限循环

动画类型:
Camera

DOAspect(float to, float duration)
DOColor(Color to, float duration)
DOFarClipPlane(float to, float duration)
DOFieldOfView(float to, float duration)
DONearClipPlane(float to, float duration)
DOOrthoSize(float to, float duration)
DOPixelRect(Rect to, float duration)
DORect(Rect to, float duration)
DOShakePosition(float duration, float/Vector3 strength, int vibrato, float randomness, bool fadeOut)
DOShakeRotation(float duration, float/Vector3 strength, int vibrato, float randomness, bool fadeOut)



Transform

Move
 
DOMove(Vector3 to, float duration, bool snapping) 将目标的位置移动到给定值。
DOMoveX/DOMoveY/DOMoveZ(float to, float duration, bool snapping) 将目标的位置移动到给定值,仅对所选轴进行补间。
DOLocalMove(Vector3 to, float duration, bool snapping) 将目标的(Local)位置移动到给定值。
DOLocalMoveX/DOLocalMoveY/DOLocalMoveZ(float to, float duration, bool snapping) 将目标的(Local)位置移动到给定值,仅对所选轴进行补间。
DOJump(Vector3 endValue, float jumpPower, int numJumps, float duration, bool snapping) 目标将跳跃到给定坐标     
DOLocalJump(Vector3 endValue, float jumpPower, int numJumps, float duration, bool snapping) 目标将跳跃到给定坐标
 
 
 
 
 
 
备注:(snapping如果TRUE,补间将平滑地将所有值捕捉到整数。)
Rotate
DORotate(Vector3 to, float duration, RotateMode mode)
DORotateQuaternion(Quaternion to, float duration)
DOLocalRotate(Vector3 to, float duration, RotateMode mode)
DOLocalRotateQuaternion(Quaternion to, float duration)
DOLookAt(Vector3 towards, float duration, AxisConstraint axisConstraint = AxisConstraint.None, Vector3 up = Vector3.up)
Scale
DOScale(float/Vector3 to, float duration)
DOScaleX/DOScaleY/DOScaleZ(float to, float duration)
Punch – no FROM
DOPunchPosition(Vector3 punch, float duration, int vibrato, float elasticity, bool snapping)
DOPunchRotation(Vector3 punch, float duration, int vibrato, float elasticity)
DOPunchScale(Vector3 punch, float duration, int vibrato, float elasticity)
Shake – no FROM
DOShakePosition(float duration, float/Vector3 strength, int vibrato, float randomness, bool snapping, bool fadeOut)
DOShakeRotation(float duration, float/Vector3 strength, int vibrato, float randomness, bool fadeOut)
DOShakeScale(float duration, float/Vector3 strength, int vibrato, float randomness, bool fadeOut)
Path – no FROM
DOPath(Vector3[] waypoints, float duration, PathType pathType = Linear, PathMode pathMode = Full3D, int resolution = 10, Color gizmoColor = null)
DOLocalPath(Vector3[] waypoints, float duration, PathType pathType = Linear, PathMode pathMode = Full3D, int resolution = 10, Color gizmoColor = null)
Blendable tweens
DOBlendableMoveBy(Vector3 by, float duration, bool snapping)
DOBlendableLocalMoveBy(Vector3 by, float duration, bool snapping)
DOBlendableRotateBy(Vector3 by, float duration, RotateMode mode)
DOBlendableLocalRotateBy(Vector3 by, float duration, RotateMode mode)
DOBlendableScaleBy(Vector3 by, float duration)
PRO ONLY ➨ Spiral – no FROM
DOSpiral(float duration, Vector3 axis = null, SpiralMode mode = SpiralMode.Expand, float speed = 1, float frequency = 10, float depth = 0, bool snapping = false)

Tween

These are shortcuts that actually tween other tweens properties. I bet you didn't think you could do it :P

Expand all
DOTimeScale(float toTimeScale, float duration)

 

 

使用案例:

弹性效果,Q弹的效果(

DOBlendableScaleBy

using UnityEngine;
using DG.Tweening;

public class PuTong : MonoBehaviour
{
void Start()
{
//数值根据场景修改
//transform.DOBlendableMoveBy(new Vector3(0, 50,0), 2).SetEase(Ease.OutElastic).SetLoops(-1, LoopType.Yoyo);
transform.DOBlendableScaleBy(new Vector3(2, 2,0), 2).SetEase(Ease.OutElastic).SetLoops(-1, LoopType.Yoyo);
}
}

 

Q弹

transform.DOShakeScale(2, new Vector3(3, 2, 0));
posted @ 2021-06-02 16:54  哒哒哒~~~  阅读(709)  评论(0编辑  收藏  举报