Unity3D插件之FingerGestures:手势插件

功能较多,目前刚用到,点选功能和双指缩放功能。


点选功能的官方教程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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值