ItweenPath使用
来源:互联网 发布:怎么开淘宝网店货源 编辑:程序博客网 时间:2024/06/01 08:48
ItweenPath可以为物体可视化绘制一条路径,一般由最多十个点组成的路径,路径可以直接在编辑器中拖动,也可以通过代码来动态进行设置。
新建一个场景,添加一个精灵,挂上ItweenPath的脚本
此时在scene中可以看到一条路径,可以拖动上面的点自定义一条路径出来如下图:
接下来添加一个测试脚本test.cs
脚本首先要获取到场景中的path路径,然后作为Itween中MoveTo里面的参数,执行移动
代码如下:
using UnityEngine;using System.Collections;public class test : MonoBehaviour { private Vector3[] path; // Use this for initialization void Start () { path = iTweenPath.GetPath("path"); iTween.MoveTo(this.gameObject, iTween.Hash("path", path, "time", 5, "easetype", iTween.EaseType.spring)); } // Update is called once per frame void Update () { }}
运行,就可以看到图标按照路径开始移动。
接下来是自定义ItweenPath路径,我们可以设定路径中的某个点为代码可以控制的点。
首先,在场景中建造六个空物体,它们的位置设定为路径中经过的位置。
将这些物体的位置设定为路径中的点需要用到ItweenPath中的Set方法。
代码如下:
using UnityEngine;using System.Collections;using System.Collections.Generic;public class test : MonoBehaviour { private Vector3[] path; private List<GameObject> go_list; // Use this for initialization void Start () { go_list = new List<GameObject>(10); for (int i = 0; i < 6; i++) { go_list.Add(GameObject.Find((i+1).ToString())); } path = iTweenPath.GetPath("path"); for (int j = 0; j < 6; j++) { path[j].Set(go_list[j].transform.position.x, go_list[j].transform.position.y, go_list[j].transform.position.z); } iTween.MoveTo(this.gameObject, iTween.Hash("path", path, "time", 5, "easetype", iTween.EaseType.spring)); } // Update is called once per frame void Update () { }}
0 0
- ItweenPath使用
- iTween之iTweenPath的使用
- Unity DoTween加iTweenPath的简单使用
- itween插件的使用:脚本itweenPath和event的使用
- itween插件的使用:脚本itweenPath和event的使用
- 塔防游戏中iTweenPath路点插件的使用
- javascript 中调用itween 及itweenPath
- iTween基础之iTweenPath(自定义路径移动)
- iTween基础之iTweenPath(自定义路径移动)
- iTween基础之iTweenPath浅析(自定义路径移动)
- 使用
- 使用
- 使用
- 使用
- 使用
- 使用
- 使用++,--
- 使用$@ $!
- web开发http communication tools
- 王爽 汇编 课程设计1
- Object-Oriented Programming with Objective-C
- python获取系统时间戳
- [总结]RTMP流媒体技术零基础学习方法
- ItweenPath使用
- (一)数据结构线性表的C++实现
- Android--Fragment
- Android ORM数据库框架之-greenDao(一)
- 第一篇博客
- java.lang.IllegalArgumentException: Page directive: invalid value for import
- oracle中V$SESSION的用法
- jquery实现菜单树
- 蚕吃桑叶吐丝,蜂采花酿蜜,人吃饭长精神