unity中的动画制做方法

Unity中的动画制做方法

一、DOTween

DoTween在5.0版本中已经用到了,到官网下载好插件以后,而后经过在项目中导入头using DG.Tweening;便可。php

一些经常使用的API函数

DOMove(this Transform target, Vector3 endValue, float duration, bool snapping = false);

该函数主要是用来移动选中的对象的,endValue表示须要移到的坐标,duration为持续的时间。api

ScaleTo(GameObject target, Vector3 scale, float time)

该函数表示缩放的比例,sacle对应该对象的scale属性,在对应放大或者缩小的时候能够看到该属性的变换。app

DOShakePosition(this Transform target, float duration, float strength = 1f, int vibrato = 10, float randomness = 90f, bool snapping = false)

哈哈,这个函数有点意思,能够作到震屏的效果,项目中的道具要作特效能够用它来作,达到颤动的效果。dom

其余一些好玩的有意思的函数能够去官方网站查看,网址http://dotween.demigiant.com/documentation.php函数

二、ITween

一些经常使用的API函数

现有项目中用的就是ITween来实现一些游戏特效的,较为经常使用的API函数
有:动画

MoveTo(GameObject target, Vector3 position, float time)
MoveTo(GameObject target, Hashtable args)

其中hashtable表示一连串的数据信息,对应键/值的值。网站

其官方网址:http://www.itween.pixelplacement.com/documentation.php好像一直在更新。貌似ITween的更加完善一点。this

项目中一些小应用

在打开游戏面板的时候须要有放大而后进行缩小的同步操做,采用Dotween的序列动画来作,其代码以下:插件

Sequence mySequence = DOTween.Sequence();
    Tweener move1 = this.transform.DOLocalMove(new Vector3(160, -13, 0), 1f, false);
    Tweener scale1 = this.transform.DOScale(0, 2f).OnComplete(() => this.gameObject.SetActive(false));
    mySequence.Append(move1);
    mySequence.Join(scale1);

效果是实现了,不过感受还有点卡顿,有待进一步改进。code

相关文章
相关标签/搜索