1.//变量插值方法
DOTween.To(() => dtV, x => dtV = x, new Vector3(10, 10, 10), 2);// DoTween.To(表达式1()目标变量,表达式2(目标变量=变量,变量值),变化时间,)
//当前位置到世界坐标下移动
bgt.transform.DOMove(s, 0.5f, true ).OnComplete(() =>
{
UM.bagPanel.SetActive(false);
UM.UI_btns.SetActive(true);
});
2.//当前位置到局部坐标下移动
bgt.transform.DOLocalMove(s, 0.5f, true ).OnComplete(() =>
{
UM.bagPanel.SetActive(false);
UM.UI_btns.SetActive(true);
});
3.//DGT倒放
bgt.transform.DOMove(e, 0.25f, true );
//Tweener对象保存DG返回的动画,设置动画不被销毁时可倒叙播放
Tweener tweener = bgg.transform.DOMove(pe, 0.5f, true);//重复执行时会创建多个动画对象耗费性能,(不接收动画对象直接运行)
tweener.SetAutoKill(false);
tweener.Pause();//暂停
//bgt.transform.DOPlayForward();//+
bgt.transform.DOPlayBackwards();//-
4.//From()
bgt.transform.DOMoveX(5, 1f)//默认从初始位置移动到5,
bgt.transform.DOMoveX(5, 1f).From();//添加From()从5移动到初始位置
bgt.transform.DOMoveX(5, 1f).From(true);//填入参数时:从相“对位”置移动到初始位置
5.//曲线/事件函数
Tweener//DG返回对象
tweener.SetEase(Ease.InBack);//设置曲线(枚举类型)
public enum Ease
{
Unset = 0,
Linear = 1,
InSine = 2,
OutSine = 3,
InOutSine = 4,
InQuad = 5,
OutQuad = 6,
InOutQuad = 7,
InCubic = 8,
OutCubic = 9,
InOutCubic = 10,
InQuart = 11,
OutQuart = 12,
InOutQuart = 13,
InQuint = 14,
OutQuint = 15,
InOutQuint = 16,
InExpo = 17,
OutExpo = 18,
InOutExpo = 19,
InCirc = 20,
OutCirc = 21,
InOutCirc = 22,
InElastic = 23,
OutElastic = 24,
InOutElastic = 25,
InBack = 26,
OutBack = 27,
InOutBack = 28,
InBounce = 29,
OutBounce = 30,
InOutBounce = 31,
Flash = 32,
InFlash = 33,
OutFlash = 34,
InOutFlash = 35,
INTERNAL_Zero = 36,
INTERNAL_Custom = 37
}
tweener.SetLoops(2);//设置循环次数
tweener.OnComplete(() =>//表达式形式在大括号中直接写入语句/或直接传入“方法”
{
UM.bagPanel.SetActive(false);
UM.UI_btns.SetActive(true);
});
6.//生命周期//与其他脚本语言相似常用OnComplete()
7.//文字动画
text.DOText("文字动画",2f)/参数:文本动画时间
8.//相机震动
transform.DOShakePosition(1);//参数震动强度
transform.DOShakePosition(1,new Vector3(1,1,0));//参数震动强度,方向约束Vector3(3,3,0)约束的值也可以控制强度
9.//颜色/阿尔法通道(UI)
text.DOColor(Color.cyan, 1f);
text.DOFade(1, 1f);
DGT
2020-09-22