标签:style blog http io color os ar 使用 sp
FingerGestures 下载地址(免积分的)点击打开链接FingerGestures v3.1
原价$45
https://www.assetstore.unity3d.com/en/#!/content/1044
请支持正版
1,unity导入FingerGestures 包,
2,找到FingerGestures的Prefabs如下图:
将此Prefabs拖入Hierarchy的根节点如下图:
3,选中需要加入手势识别的物体
在菜单中入加识别的脚本,如下图:
本例采用Swipe Recognizer(滑动识别)
4,添加好脚本后在物体上可以看到添加的脚本如下图:
Message Name表示滑动时,组件调用的方法名
Message Target 表示调动的发送消息的目标(空的GameObject 绑定一个脚本,脚本中含有OnSwipe方法)
public void OnSwipe(SwipeGesture gesture) { // 完整的滑动数据 Vector2 move = gesture.Move; // 滑动的速度 float velocity = gesture.Velocity; // 大概的滑动方向 FingerGestures.SwipeDirection direction = gesture.Direction;
Debug.Log("OnSwipe,move=" + move.ToString() + ",velocity=" + velocity + ",direction=" + direction.ToString()); } |
到此就可以成功滑动了。
其它的手势也基本类似
附上一些用法:
FingerGestures提供了3种不同的方法来检测由用户执行的拖动手势。
标签:style blog http io color os ar 使用 sp
原文地址:http://blog.csdn.net/wiker_yong/article/details/40538975