DoTween插件
DoTween的下载
在Unity项目中找到Windows选择Asset Store。

之后将会跳转到Unity商店, 搜索Dotween, 选择一个免费的Dotween插件(也可以选付费的,看个人需求)加入我的资源(需要登陆)之后下载完成后导入Unity中。
在Unity的Project中会出现Plugin和Resource两个文件则导入成功。

DoTween的使用
用代码实现Dotween的使用:先创建一个Cube物体,然后加上脚本。

在写代码时要注意要加上using DG.Tweening;的命名空间。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
移动(Move)
//对物体进行移动,前一个参数是坐标,后一个是时间
transform.DOMove(new Vector3(1,1,1),2);//世界坐标,将物体移动到1,1,1 用时2s
transform.DOLocalMove(new Vector3(1, 1, 0), 2);//局部坐标
transform.DOMoveX(1,2);//只对X轴移动
transform.DOMoveY(2,2);//只对Y轴移动
transform.DOMoveZ(2,2);//只对Z轴移动
//另一种移动方式
transform.DOMove(Vector3.one,2);//将物体移动到1,1,1,Vector3.one*2是可以将移动距离*2
旋转(Rotate)
transform.DORotate(new Vector3(0,90,0),2);//对物体进行旋转改变角度Vector3(0,90,0)是绕Y轴旋转90°
transform.DORotateQuaternion(new Quaternion(0.1f,0.1f,0.1f,0.1f),

1万+

被折叠的 条评论
为什么被折叠?



