Unity开发游戏途中可以使用unity dotweenn插件吗 可以的话可以发个吗?

玩转Unity3d培训中的DOTween插件
玩转Unity3d培训中的DOTween插件
浏览次数:675
浏览次数:1248
浏览次数:1095
浏览次数:1350
浏览次数:1478
如果你对以下课程意犹未尽,,查看全部课程
HTML5全栈开发
HTML5最新课程
156 人在学
c#编程概述
C#快速入门
简单又好玩
120 人在学
没有账号?
s后重新发送
已有账号?
已有账号?
验证码确认
话题标题:
400-877-8190
登录后反馈博主最新文章
博主热门文章
您举报文章:
举报原因:
原文地址:
原因补充:
(最多只允许输入30个字)Unity插件DOTween教程(三)-GAD腾讯游戏开发者平台代码环境:
  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: TRUE
public static bool defaultAutoK
2&& 构建新的tweens后,会自动play。保持该值,我们则无需要手动调用play
// Summary:
Default autoPlay behaviour for new tweens.
Default: AutoPlay.All
public static AutoPlay defaultAutoP
3 默认的运动方式,主要表现是开始执行时,快速,在后期会逐步减速。该算法在执行时间长度比较短时看着比较合理舒适,但是如果出现类似距离较长,时间也相对较长时,就容易发现在后期有点很不好接受的缓慢移动。此时就需要考虑更改运动方式。
// Summary:
Default ease applied to all new Tweeners (not to Sequences which always have
Ease.Linear as default).
Default: Ease.InOutQuad
public static Ease defaultEaseT
// Summary:
Sets the ease of the tween.
If applied to Sequences eases the whole sequence animation
public static T SetEase&T&(this T t, Ease ease) where T : T
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:
The end value to reach
The duration of the tween
If TRUE the tween will smoothly snap all values to integers
public 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:
The end value to reach
The duration of the tween
Rotation mode
public 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:
The end value to reach
The duration of the tween
public 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
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:
The action to perform with the tweened value
startValue:
The value to start from
The end value to reach
The duration of the virtual tween
public 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:
The tween to append
public 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 started
public 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
The tween to insert
public 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
The callback to insert
public 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:
If TRUE completes the tweens before killing them
public static int Kill(object targetOrId, bool complete = false);
以下是一些测试例子和执行后的效果图。
[ContextMenu("DoTweenAlpha")]
void DoTweenAlpha()
Debug.Log("DoTweenAlpha");
UIRect uiRect = m_uiRectA
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_uiRectA
if (uiRect != null)
DOTween.Kill("Tween", true);
[ContextMenu("DoTweenKillAlpha")]
void DoTweenKillAlpha()
Debug.Log("DoTweenKillAlpha");
UIRect uiRect = m_uiRectA
if (uiRect != null)
DOTween.Kill("Tween", false);
[ContextMenu("DoSequenceAlpha")]
void DoSequenceAlpha()
Debug.Log("DoSequenceAlpha");
UIRect uiRect = m_uiRectA
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_uiRectA
if (uiRect != null)
DOTween.Kill("Sequence", true);
[ContextMenu("DoSequenceKillAlpha")]
void DoSequenceKillAlpha()
Debug.Log("DoSequenceKillAlpha");
UIRect uiRect = m_uiRectA
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执行后的效果图:
阅读(...) 评论()程序写累了,就来玩玩酷跑小游戏吧,嘿嘿。
雨松MOMO送你一首歌曲,嘿嘿。
UGUI研究院之界面中使用DoTween(七)
UGUI研究院之界面中使用DoTween(七)
围观223340次
编辑日期: 字体:
因为NGUI中已经有UITween了,可是UGUI中是没有这样的Tween的。我看过UGUI的Demo它的实现方式是用Animator来做的,这样每一个需要移动的对象就要挂上一个AmimationController并且还要去编辑动画。。 想想都恐怖,我觉得真没必要那么做。。
我强烈建议新项目使用DoTween。 网址要翻墙,不然打不开。不要紧后面我把下载地址提供出来。 (目前DoTween还是测试版本)DoTween的文档写的非常详细,所以我就简单的只写两句代码,为大家抛砖引玉一下即可。
不得不说的是,因为在做游戏暂停的时候通常会使用Time.Scale = 0 ,可是暂停的时候UI如果需要继续有动画怎么办呢?在DoTween中只需要设置
tweener.SetUpdate(true); 即可。意思就是这个Tween是忽略TimeScale,如果不写的话 tweener.SetUpdate 是 false。
using DG.T //不能少了这个命名空间。
12345678910111213141516171819
void Start ()
//让TimeScale = 0
Time.timeScale = 0;&
Image image = transform.Find("Image").GetComponent&Image&();
//调用DOmove方法来让图片移动
Tweener tweener = image.rectTransform.DOMove(Vector3.zero,1f);
//设置这个Tween不受Time.scale影响
tweener.SetUpdate(true);
//设置移动类型
tweener.SetEase(Ease.Linear);
tweener.onComplete = delegate() {
Debug.Log("移动完毕事件");
image.material.DOFade(0,1f).onComplete = delegate() {
Debug.Log("褪色完毕事件");
Tween的移动类型有很多种,比如匀速运动、加速运动、减速运动,等等。如果你拿捏不准你需要用什么移动类形式。
你可以在这里预览一下那种移动类型更佳适合你。
代码中我们设置了图片的移动 和 褪色,因为移动的Tween设置了忽略Time.Scale,所以代码中Time.Scale =0时,图片的Tween响应了位移操作,然后褪色的Tween却没有。
最后是DoTween的类库,如果你没有翻墙就下载我的吧, 是最新的。 欢迎大家在留言处和我一起讨论,加油!Fighting!
本文固定链接:
转载请注明:
雨松MOMO提醒您:亲,如果您觉得本文不错,快快将这篇文章分享出去吧 。另外请点击网站顶部彩色广告或者捐赠支持本站发展,谢谢!
作者:雨松MOMO
专注移动互联网,Unity3D游戏开发
如果您愿意花10块钱请我喝一杯咖啡的话,请用手机扫描二维码即可通过支付宝直接向我捐款哦。
您可能还会对这些文章感兴趣!}

我要回帖

更多关于 dotween插件下载 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信