功能較多,目前剛用到,點選功能和雙指縮放功能。
點選功能的官方教程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