代码环境:

  unity:version5.3.4.f1

DOTween:v1.0.312

  IDE:Microsoft visual studio Community 2015

DOTween中几个需要注意的变量和函数功能说明:

1 tweens对象完成后会自动销毁,如此我们基本不用关心DOTween的内存销毁问题。

        //// Summary://     Default autoKillOnComplete behaviour for new tweens.//     Default: TRUEpublic static bool defaultAutoKill;

2   构建新的tweens后,会自动play。保持该值,我们则无需要手动调用play

        //// Summary://     Default autoPlay behaviour for new tweens.//     Default: AutoPlay.Allpublic static AutoPlay defaultAutoPlay;

3 默认的运动方式,主要表现是开始执行时,快速,在后期会逐步减速。该算法在执行时间长度比较短时看着比较合理舒适,但是如果出现类似距离较长,时间也相对较长时,就容易发现在后期有点很不好接受的缓慢移动。此时就需要考虑更改运动方式。

        //// Summary://     Default ease applied to all new Tweeners (not to Sequences which always have//     Ease.Linear as default).//     Default: Ease.InOutQuadpublic static Ease defaultEaseType;//// Summary://     Sets the ease of the tween.//     If applied to Sequences eases the whole sequence animationpublic static T SetEase<T>(this T t, Ease ease) where T : Tween;

4 DOTween中有两套不同的调用方式=》
shortcuts way,但是需要针对不同对象,需要调用不一样对象:
        //// Summary://     Tweens a Transform's localPosition to the given value. Also stores the transform//     as the tween's target so it can be used for filtered operations//// Parameters://   endValue://     The end value to reach////   duration://     The duration of the tween////   snapping://     If TRUE the tween will smoothly snap all values to integerspublic static Tweener DOLocalMove(this Transform target, Vector3 endValue, float duration, bool snapping = false);//// Summary://     Tweens a Transform's localRotation to the given value. Also stores the transform//     as the tween's target so it can be used for filtered operations//// Parameters://   endValue://     The end value to reach////   duration://     The duration of the tween////   mode://     Rotation modepublic static Tweener DOLocalRotate(this Transform target, Vector3 endValue, float duration, RotateMode mode = RotateMode.Fast);//// Summary://     Tweens a Transform's localScale to the given value. Also stores the transform//     as the tween's target so it can be used for filtered operations//// Parameters://   endValue://     The end value to reach////   duration://     The duration of the tweenpublic static Tweener DOScale(this Transform target, Vector3 endValue, float duration);

generic way,大部分的执行都可以用同类型的接口。
如下函数,只要是float类型数值,都可以符合调用要求。我个人使用最多的就是应用在alpha上,处理渐隐渐现效果很好。
        //// Summary://     Tweens a virtual property from the given start to the given end value and implements//     a setter that allows to use that value with an external method or a lambda//     Example://     To(MyMethod, 0, 12, 0.5f);//     Where MyMethod is a function that accepts a float parameter (which will be the//     result of the virtual tween)//// Parameters://   setter://     The action to perform with the tweened value////   startValue://     The value to start from////   endValue://     The end value to reach////   duration://     The duration of the virtual tweenpublic static Tweener To(DOSetter<float> setter, float startValue, float endValue, float duration);

5 关于sequence
Sequences are like Tweeners, but instead of animating a property or value they animate other Tweeners or Sequences as a group.
比较简单的Sequence,可以直接用如下函数增加Append / Join:
 //// Summary://     Adds the given tween to the end of the Sequence. Has no effect if the Sequence//     has already started//// Parameters://   t://     The tween to appendpublic static Sequence Append(this Sequence s, Tween t);//// Summary://     Inserts the given tween at the same time position of the last tween added to//     the Sequence. Has no effect if the Sequence has already startedpublic static Sequence Join(this Sequence s, Tween t);

如果是比较复杂的,建议直接使用insert,如此可以随意的控制加入tween的时间节点

        //// Summary://     Inserts the given tween at the given time position in the Sequence, automatically//     adding an interval if needed. Has no effect if the Sequence has already started//// Parameters://   atPosition://     The time position where the tween will be placed////   t://     The tween to insertpublic static Sequence Insert(this Sequence s, float atPosition, Tween t);//// Summary://     Inserts the given callback at the given time position in the Sequence, automatically//     adding an interval if needed. Has no effect if the Sequence has already started//// Parameters://   atPosition://     The time position where the callback will be placed////   callback://     The callback to insertpublic static Sequence InsertCallback(this Sequence s, float atPosition, TweenCallback callback);

6 关于Kill函数:特意提出该接口,是因为针对于Sequence,调用DOTween.Kill("Sequence", true),并不能在kill之前complete,不确定是其本身的bug还是我对接口的理解不对。

        //// Summary://     Kills all tweens with the given ID or target and returns the number of actual//     tweens killed//// Parameters://   complete://     If TRUE completes the tweens before killing thempublic static int Kill(object targetOrId, bool complete = false);

以下是一些测试例子和执行后的效果图。

    [ContextMenu("DoTweenAlpha")]void DoTweenAlpha(){Debug.Log("DoTweenAlpha");UIRect uiRect = m_uiRectAni;if (uiRect != null){DOTween.To(x => uiRect.alpha = x, 1.0f, 0.0f, 5.0f).SetId("Tween");}}[ContextMenu("DoTweenKillCompleteAlpha")]void DoTweenKillCompleteAlpha(){Debug.Log("DoTweenKillCompleteAlpha");UIRect uiRect = m_uiRectAni;if (uiRect != null){DOTween.Kill("Tween", true);}}[ContextMenu("DoTweenKillAlpha")]void DoTweenKillAlpha(){Debug.Log("DoTweenKillAlpha");UIRect uiRect = m_uiRectAni;if (uiRect != null){DOTween.Kill("Tween", false);}}[ContextMenu("DoSequenceAlpha")]void DoSequenceAlpha(){Debug.Log("DoSequenceAlpha");UIRect uiRect = m_uiRectAni;if (uiRect != null){Sequence sequence = DOTween.Sequence();sequence.Append(DOTween.To(x => uiRect.alpha = x, 1.0f, 0.0f, 5.0f));sequence.SetId("Sequence");}}[ContextMenu("DoSequenceKillCompleteAlpha")]void DoSequenceKillCompleteAlpha(){Debug.Log("DoSequenceKillCompleteAlpha");UIRect uiRect = m_uiRectAni;if (uiRect != null){DOTween.Kill("Sequence", true);}}[ContextMenu("DoSequenceKillAlpha")]void DoSequenceKillAlpha(){Debug.Log("DoSequenceKillAlpha");UIRect uiRect = m_uiRectAni;if (uiRect != null){DOTween.Kill("Sequence", false);}}

执行顺序:
DoTweenAlpha->DoTweenKillAlpha(正确kill,并没有complete);DoTweenAlpha->DoTweenKillCompleteAlpha(正确kill,并成功complete)
DoSequenceAlpha->DoSequenceKillAlpha(正确kill,并没有complete);DoSequenceAlpha->DoSequenceKillCompleteAlpha(正确kill,并没有成功complete)
附上一张DoSequenceAlpha->DoSequenceKillCompleteAlpha执行后的效果图:

转载于:https://www.cnblogs.com/xiaolanyuan/p/5627343.html

[DOTween]使用过程中的一些注意事项记录相关推荐

  1. as安装过程中gradle_在安装钢结构平台过程中需要注意哪些事项?

    钢制平台货架是在厂房面积有限的情况下采用货架作为阁楼支撑,并可以设计多层(通常2-3层)的存储货架,阁楼可以采用楼梯或者液压升降平台做为登高设施,利用金属专用楼板作为楼层区分,每层可以放置不同物品的货 ...

  2. 变频器使用过程中应该注意的事项有哪些?

    变频器使用不当,不但不能很好的发挥其优良的功能,而且还可能损坏变频器及其设备,或造成干扰影响等,所以在使用的过程中有很多事项是我们应该注意的,今天我们就一起来看下变频器在使用过程中应该注意的事项都是哪 ...

  3. Android studio安装过程中入的坑的记录与记录

    Android studio安装过程中入的坑的记录与记录 * 由于最近项目的需求,所以最近一直在配置安卓的开发环境,之前用的是Eclipse + ADT的模式开发的,配置环境也花了一些时间,但是由于谷 ...

  4. VS2008运行过程中出现regsvr32问题解决方法记录

    VS2008运行过程中出现regsvr32问题解决方法 vs2008运行工程文件过程中提示regsvr32出现问题,此时我的项目中有3个工程,两个是依赖,第三个是我建立的运行工程,出现这个问题之后,我 ...

  5. libx264编码过程中修改码率踩坑记录

    问题来源于项目中的一个需求,根据当前网络环境实时调整libx264的码率参数,从而让视频播放更加流畅. 1.设置码率调整算法为ABR. 2.初始化,并提供一个接口供探测网络环境的线程调用.写法大概类似 ...

  6. mongodb adminmongo 使用过程中的一些小问题记录

    1 mongo下载地址 http://dl.mongodb.org/dl/win32/x86_64 2 启动 ./mongod --dbpath=c:/data 3 adminmongo(一款mong ...

  7. 使用某为开发板,在项目过程中遇到的坑,记录一下,希望以后不会遇到

    某为的开发板有这样一处lcd电源控制如图 下面是关于这个ao3415A的手册和官方的说法: 我们可以看到,这个管子是典型的Pmos管,官方的文档也写得很清楚是pmos,其内部的二极管方向是D到S,那么 ...

  8. 天拓分享 | 变频器使用过程中哪些事项要注意?

    变频器使用不当,不但不能很好的发挥其优良的功能,而且还可能损坏变频器及其设备,或造成干扰影响等,所以在使用的过程中有很多事项是我们应该注意的,今天我们就一起跟着天拓四方技术工程师来看下变频器在使用过程 ...

  9. @Value注解使用过程中遇到的一些坑

    笔者结合之前的一些经验教训,再结合一些资料总结了一下@Value注解使用过程中的一些注意事项. 目录 一.@Value无法读取配置文件中的参数 二.@Value出现中文乱码 三.@Value使用的一些 ...

最新文章

  1. Makefile所有内嵌函数
  2. 一文看懂95%置信区间
  3. [转] boost::function用法详解
  4. 部署WAR包实时查看Tomcat的状态和日志
  5. Cannot add product to Opportunity in Fiori - RFC error
  6. python使用全局变量的坑,要使用global
  7. 三星Galaxy Fold全球翻车后 推迟发售时间进一步改进
  8. 光流(六)--L2范数Horn–Schunck 光流法及应用demo
  9. ailed to send crash report due to a network error: SocketException: OS Error: 信号灯超时时间已到 , errno = 12
  10. 带宽,传输速率,吞吐量三者之间的关系与区别
  11. getlasterror 126
  12. 餐厅小票打印模板_收银系统小票标签设置
  13. 【嵌入式 C】C语言中格式输出二进制的两种方法
  14. 基于JavaScript的餐厅点餐系统微信小程序的设计与实现
  15. 柠檬班软件测试靠谱吗 全程班毕业后7天就拿到了offer
  16. vue文件夹上传组件选哪个好?
  17. Edge被恶意篡改主页
  18. 一文带你看懂工厂模式
  19. 基于html、css的个人网站(网页制作期末作业)
  20. 【STC8学习笔记】STC8A8K64S4A12 程序烧录及使一个LED闪烁

热门文章

  1. mysql-connector-odbc-5.3.12-win32.msi安装步骤
  2. Linux生成ascii文件,linux下ASCII转HEX的实现
  3. python变量赋值给数组_python 变量,数组,字符串
  4. VScode环境配置C/C++
  5. spark Drive 与Executor
  6. OD常用快捷键(对比SoftICE)
  7. Zephyr_Bindings目录作用
  8. 数字员工到岗,普通员工惊慌?先别急,往下看
  9. centos7---mysql5.7主从复制读写分离
  10. SQLserver nText和varchar 不兼容