DoTween

来源:互联网 发布:淘宝店铺第三方 编辑:程序博客网 时间:2024/06/11 14:26

用了几天DoTween,发表一下见解!

DoTween相比于ITween确实方便了许多,执行效率也高,可是我感觉对于新手来说ITween更容易上手,不是说DoTween比较难学,而是官方文档太含糊了!没ITween的简洁明了!

举个例子吧!之前使用DoTweenPath的时候想在中途改变速度,可是很鸡肋,DoTween的一切都是动画执行之前设置好的!查遍了官方文档也找不出办法!最后在GitHub上发现有人说了句TimeScale,我累个擦!官方完全没给我说好吧?还是我没看见?

而且DoTween在网上的介绍大部分都是一个小小示例!完全应用不到使用中,不是把这个物体移动到那就是移动到这!放大缩小!简简单单的~假如我要一个物体向另一个移动的物体移动怎么办?(我也没找到好的办法,知道的人麻烦分享一下)!

不过!为了学习还是继续用用吧!大家有问题可以交流!


补充:终于!还是找到了解决方案!一款插件的强大不在于你会不会用!而是他本身就很强大!下面贴出从GitHub找出的代码!GItHub真心强大,比百度搜出来的有用多了!闭关锁国啊!

public class Follow : MonoBehaviour
{
public Transform target; // Target to follow
Vector3 targetLastPos;
Tweener tween;


void Start()
{
// First create the "move to target" tween and store it as a Tweener.
// In this case I'm also setting autoKill to FALSE so the tween can go on forever
// (otherwise it will stop executing if it reaches the target)
tween = transform.DOMove(target.position, 2).SetAutoKill(false);
// Store the target's last position, so it can be used to know if it changes
// (to prevent changing the tween if nothing actually changes)
targetLastPos = target.position;
}


void Update()
{
// Use an Update routine to change the tween's endValue each frame
// so that it updates to the target's position if that changed
if (targetLastPos == target.position) return;
// Add a Restart in the end, so that if the tween was completed it will play again
tween.ChangeEndValue(target.position, true).Restart();
targetLastPos = target.position;
}
}

0 0
原创粉丝点击