安装方式
- 地址:
https://developer.leapmotion.com/unity
Core 包
Leap Motion Interaction Engine 包
其他包(如果你需要的话)
安装界面
进入界面后
image.png- 添加Trigger
按照提示在 Input Manager 添加两个东西:
-> Edit/Project Settings/Input/Axes,加两轴,
一个 RightVRTriggerAxis,Axis 为 10th Joystick;
另一个LeftVRTriggerAxis , Axis 为 9th Joystick:
- 弄个小程序做测试
添加个Cube,然后在它上面挂上 InteractionBehaviour, 创建个脚本CubeController 也挂到它身上,脚本的代码如下:
...
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CubeController : MonoBehaviour
{
Leap.Unity.Interaction.InteractionBehaviour interactionBehaviour;
// Use this for initialization
void Start()
{
interactionBehaviour = GetComponent<Leap.Unity.Interaction.InteractionBehaviour>();
// 悬停事件
interactionBehaviour.OnHoverBegin = () =>
{
Debug.Log("刚开始悬停...");
};
interactionBehaviour.OnHoverStay = () =>
{
//Debug.Log("悬停保持中...");
};
interactionBehaviour.OnHoverEnd = () =>
{
Debug.Log("悬停结束");
};
// 抓取事件
interactionBehaviour.OnGraspBegin = () =>
{
Debug.Log("抓取开始...");
};
interactionBehaviour.OnGraspStay = () =>
{
// Debug.Log("抓取保持...");
};
interactionBehaviour.OnGraspEnd = () =>
{
Debug.Log("抓取结束...");
};
// 触击事件
interactionBehaviour.OnContactBegin = () =>
{
Debug.Log("开始触击..");
};
interactionBehaviour.OnContactStay = () =>
{
// Debug.Log("保持触击..");
};
interactionBehaviour.OnContactEnd = () =>
{
Debug.Log("触击结束");
};
}
}
...
网友评论