unity中的动画制作方法

Unity中的动画制作方法##

1、DOTween###

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

一些常用的API函数###

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

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

ScaleTo(GameObject target, Vector3 scale, float time)

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

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

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

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

2、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的更加完善一点。

项目中一些小应用###

在打开游戏面板的时候需要有放大然后进行缩小的同步操作,采用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);

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

原文地址:https://www.cnblogs.com/master-image/p/4928180.html