Unity DoTween加iTweenPath的简单使用
2015-04-10 16:09
501 查看
Dotween比iTween的优点
1,DoTween的通知机制使用 iTween的效率比iTween高上好几倍,iTween使用消息传递机制使用SendMessage,sendMessage使用反射实现,效率不高。
2,iTween使用的参数还是字符串,用起来有些不习惯
如果要了解DOTween详细点的也可以看这篇博客哈O(∩_∩)O~~:DOTween教程
一, 下载、文档 Dotween:http://dotween.demigiant.com/pro.php
也可以直接从Unity 的assert store下载
引入DoTween后,可在工具栏Tools--》DoTween Utility Pannel-->SetupDotween适配当前unity版本的新feature,也可打开dotween官网文档,也可以在Preferences设置
DoTween的全局信息。
二,引入Unity项目后,Dotween 的命名空间是 using DG.Tweening;
开始初始化
DoTween可操作多种变量
可使用链式编程:
三,在itween里,我一时没有发现类似iTween里很好用的iTweenpath工具,可视化创建物体运动路径
所以我把iTween里的ITweenPath类也拿来和Dotween用了。
用法:可视化创建路径
1,把ITweenPath类导入Unity后
2,新建一个空GameObject,更名为“iPath”,然后挂上iTweenPath脚本
3,给ITweenPath分配5个路径节点,然后就可以在Scene手动创建路径了
4,路径创建好了,新建一个需要移动的物体:
3D Object -->>Cube吧,然后新建C#脚本DotMove,写代码
4,回到编辑器,往cube的DoMove ipath挂上ipath,然后run————————》》,完成。
1,DoTween的通知机制使用 iTween的效率比iTween高上好几倍,iTween使用消息传递机制使用SendMessage,sendMessage使用反射实现,效率不高。
2,iTween使用的参数还是字符串,用起来有些不习惯
如果要了解DOTween详细点的也可以看这篇博客哈O(∩_∩)O~~:DOTween教程
一, 下载、文档 Dotween:http://dotween.demigiant.com/pro.php
也可以直接从Unity 的assert store下载
引入DoTween后,可在工具栏Tools--》DoTween Utility Pannel-->SetupDotween适配当前unity版本的新feature,也可打开dotween官网文档,也可以在Preferences设置
DoTween的全局信息。
二,引入Unity项目后,Dotween 的命名空间是 using DG.Tweening;
开始初始化
DOTween.Init(autoKillMode, useSafeMode, logBehaviour);不初始化则使用默认值,
// EXAMPLE A: initialize with the preferences set in DOTween's Utility Panel DOTween.Init(); // EXAMPLE B: initialize with custom settings, and set capacities immediately DOTween.Init(true, true, LogBehaviour.Verbose).SetCapacity(200, 10);
DoTween可操作多种变量
transform.DOMove(new Vector3(2,3,4), 1); rigidbody.DOMove(new Vector3(2,3,4), 1); material.DOColor(Color.green, 1);
可使用链式编程:
transform.DOPath(path, 5, PathType.CatmullRom, PathMode.Full3D, 10, Color.red) .SetLoops(100, LoopType.Yoyo) .SetEase(Ease.OutQuart) ;
三,在itween里,我一时没有发现类似iTween里很好用的iTweenpath工具,可视化创建物体运动路径
所以我把iTween里的ITweenPath类也拿来和Dotween用了。
用法:可视化创建路径
1,把ITweenPath类导入Unity后
2,新建一个空GameObject,更名为“iPath”,然后挂上iTweenPath脚本
3,给ITweenPath分配5个路径节点,然后就可以在Scene手动创建路径了
4,路径创建好了,新建一个需要移动的物体:
3D Object -->>Cube吧,然后新建C#脚本DotMove,写代码
using UnityEngine; using System.Collections; using DG.Tweening; public class DotMove : MonoBehaviour { public iTweenPath ipath; void Start() { //获取路径节点 Vector3[] path = new Vector3[ipath.nodeCount]; for (int i = 0; i < ipath.nodeCount; i++) { path[i] = ipath.nodes[i]; } //DoTween设置路径 transform.DOPath(path, 5, PathType.CatmullRom, PathMode.Full3D, 10, Color.red) .SetLoops(100, LoopType.Yoyo) .SetEase(Ease.OutQuart) ; } }
4,回到编辑器,往cube的DoMove ipath挂上ipath,然后run————————》》,完成。
相关文章推荐
- Unity_DOTween动画的学习(七)_Tweener的使用简单补充_DOText的简单演示
- Unity_DOTween动画的学习(十一)_DOTweenPath路径编辑器的使用补充_结合按钮触发不同点击事件控制播放状态_Waypoints
- Unity 动画插件 DOTween 的简单使用
- Unity_DOTween动画的学习(十)_DOTween路径编辑器的使用和技巧了解(DOTween秒杀iTween精华)
- Metaio在Unity中的简单使用
- Unity上使用Linq To XML——简单易维护的代码
- [Unity]可视化路径的插件iTween的使用
- Android绘图基础:Canvas、Paint、Path的简单使用
- Unity3d iTween Path Editor C#版不仅可让C#开发者使用,也可为JS开发者使用
- unity中使用GUI按钮实现简单的猜拳小游戏:
- unity的itween基础使用
- Python环境变量PYTHONPATH设置和easy_install简单使用
- Unity可视化路径的插件iTween的使用
- Python环境变量PYTHONPATH设置和easy_install简单使用
- unity关于StartCoroutine的简单线程使用
- Unity4.3新功能:2D工具 的简单使用教程
- unity---EZGUI简单的使用1
- 使用Unity2.0的Interceptor实现简单AOP
- Unity V3 初步使用 —— 为我的.NET项目从简单三层架构转到IOC做准备