当前位置: 首页> 健康> 母婴 > 天津哪里能做网站_新型冠状病毒_今日热点新闻素材_图片外链生成工具在线

天津哪里能做网站_新型冠状病毒_今日热点新闻素材_图片外链生成工具在线

时间:2025/7/10 1:09:26来源:https://blog.csdn.net/alizhuana/article/details/143139244 浏览次数:0次
天津哪里能做网站_新型冠状病毒_今日热点新闻素材_图片外链生成工具在线

1.LeanTween.reset()

一、工具介绍

参考:推荐开源项目:LeanTween - 为Unity 3D打造的高效缓动引擎-CSDN博客

LeanTween是一个专为Unity 3D引擎设计的高效缓动(tweening)库,它提供了简单易用的API,帮助开发者轻松实现各种复杂场景。

二、常用的方法详解


1.LeanTween.reset()

 很明了的方法,用于重置,最好在每次加载的时候进行重置,一般放在Start或者Awaik方法中使用


2.LeanTween.addListener和LeanTween.dispatchEvent

 

代码示例:

public class MoveTools : MonoBehaviour
{public GameObject ball;public MyActions action;void Start(){LeanTween.reset();LeanTween.addListener(this.gameObject, (int)MyActions.Jump, jumpUp);}void Update(){if (Input.GetKeyDown(KeyCode.Space)){Debug.Log("jump!");LeanTween.dispatchEvent((int)MyActions.Jump, this);}}void jumpUp(LTEvent e) { Debug.Log("LTEvent:" + e.ToString()); }}public enum MyActions
{Idle,Jump,
}

3.LeanTween.moveSpline

让物体按照一些列点进行移动,但是需要注意的是,第一个点和最后一个点不会经过


public class TestMoveSpline : MonoBehaviour
{public MyActions action;public List<GameObject> targets;private Vector3[] positions; //void Start(){positions = new Vector3[targets.Count];LeanTween.reset();for (int i = 0; i < targets.Count; i++){positions[i] = targets[i].transform.position;}}void Update(){if (Input.GetKeyDown(KeyCode.Space)){LeanTween.moveSpline(gameObject, positions, 3.0f);}}}

4.LeanTween.rotate系列

rotate系列有:

  • rotate(GameObject gameObject, Vector3 to, float time)
  • rotate(LTRect ltRect, float to, float time)
  • rotateLocal(GameObject gameObject, Vector3 to, float time)

  • rotateX(GameObject gameObject, float to, float time)

  • rotateY(GameObject gameObject, float to, float time)

  • rotateZ(GameObject gameObject, float to, float time)

  • rotateAround(GameObject gameObject, Vector3 axis, float add, float time)

  • rotateAroundLocal(GameObject gameObject, Vector3 axis, float add, float time)

优点:直接输入需要旋转的角度,用法也简单,妈妈再也不用担心旋转的时候发万象锁啦~

需要注意的是:旋转方向以180°为界,会寻找离当前位置最近的角度进行旋转。

后续更新ing...

关键字:天津哪里能做网站_新型冠状病毒_今日热点新闻素材_图片外链生成工具在线

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: