FingerGestures插件是基于unity推出的一款手势插件,能够轻松的实现手机手势控制,包括按下事件、抬起事件、移动事件、连击事件、长按事件等,支持触摸屏和鼠标的设计。允许用户自定义手势触发图案,需要的朋友快快下载吧!

软件特点
1:它统一了鼠标点击和用户触摸的输入模型。使得我们可以在UnityEditor里面就可以方便地进行触摸测试(而不必发布到机器上)
2:它提供了丰富的触摸、手势事件支持
3:使用符合KISS原则,不需要复杂的配置,即可实现功能
4:允许用户自定义手势触发图案(无尽之剑的手势触发技能,用它轻松实现)
FingerGestures插件使用教程
A:手指点击事件,划过事件,离开事件,鼠标点击保持不动事件。
A3.1.找到如图1所示预制体位置将其拖入场景,该预制体上面包含的脚本FingerGestures.cs包含了一些基本的初始化

A3.2在空场景中创建一个空物体,命名为Finger,点击Finger物体之后,点击工具栏component>>FingerGesture>>FingerEvent>>向物体Finger添加方法,我们首先添加的为FingerDown,点击按下事件。如图2所示

A3.3添加之后如下图2所示

新建一个脚本FingerTest,并创建一个方法,方法名要与FingerDownDetector.cs脚本中红色方框勾选的MessageName一致,方法名与写如下脚本

运行场景,Pc端点击鼠标可看到,Down时刻打印输出,方法被事件调用

B.双击事件,单击事件,拖拽事件,长按事件等
B3.1新建一个空场景,拖入FingerGesture预制体,新建一个空物体,在工具栏Component>>FingerGesture>>给其添事件监听脚本,如图所示添加拖拽事件等

值得注意的是,双击事件,需要添加TapRec,需要修改tap次数,和事件广播方法,如下图所示

,在Finger空物体上添加一个脚本如下所示,

运行可看到输出
FingerGestures效果图预览
单击屏幕
提醒一下,我点击的左下角,看到屏幕的坐标原点其实是以左下角为原点的,这就是OpenGL坐标的原点规定!
双击屏幕
滑动手势

滑动的分解过程:按下->按下事件开始->按下中->滑动开始->滑动中->滑动结束->判断滑动方向
长按手势
