功能较多,目前刚用到,点选功能和双指缩放功能。
点选功能的官方教程http://fingergestures.fatalfrog.com/docs/manual:tutorial_detect_tap,翻译整理如下:
1、安装插件
2、从插件目录Plugins/FingerGestures/Prefabs/拖动FingerGestures到Hierarchy视图里(也可以建立empty object 然后添加 “FingerGestures” component)
3、创建一个新GameObject命名为“Gestures”
4、添加TapRecognizer component到刚才新建的GameObjec“Gestures”。步骤是点击“AddComponent" > FingerGestures > Gestures > Tap
5、添加ScreenRaycaster component到“Gestures”
5、添加脚本命名为Tap.cs,并且拖动关联到“Gestures”。内容为:
using UnityEngine;
using System.Collections;
public class Tap : MonoBehaviour {
void OnTap( TapGesture gesture ) {
if (gesture.Selection) {
Debug.Log ("Tapped object: " + gesture.Selection.name);
} else {
Debug.Log ("No object was tapped at " + gesture.Position);
}
}
}
6、确认被点选的物体有collider,没有就手工AddComponent
7、运行,看到点击有collider的物体会log其名称,其他地方显示position