game_view
安裝方式
- 地址:
https://developer.leapmotion.com/unity
Core 包
Leap Motion Interaction Engine 包
其他包(如果你需要的話)
安裝界面
進(jìn)入界面后
image.png
- 添加Trigger
按照提示在 Input Manager 添加兩個(gè)東西:
-> Edit/Project Settings/Input/Axes,加兩軸削祈,
一個(gè) RightVRTriggerAxis翅溺,Axis 為 10th Joystick;
另一個(gè)LeftVRTriggerAxis , Axis 為 9th Joystick:
添加Trigger界面
- 弄個(gè)小程序做測(cè)試
添加個(gè)Cube髓抑,然后在它上面掛上 InteractionBehaviour, 創(chuàng)建個(gè)腳本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("剛開(kāi)始懸停...");
};
interactionBehaviour.OnHoverStay = () =>
{
//Debug.Log("懸停保持中...");
};
interactionBehaviour.OnHoverEnd = () =>
{
Debug.Log("懸停結(jié)束");
};
// 抓取事件
interactionBehaviour.OnGraspBegin = () =>
{
Debug.Log("抓取開(kāi)始...");
};
interactionBehaviour.OnGraspStay = () =>
{
// Debug.Log("抓取保持...");
};
interactionBehaviour.OnGraspEnd = () =>
{
Debug.Log("抓取結(jié)束...");
};
// 觸擊事件
interactionBehaviour.OnContactBegin = () =>
{
Debug.Log("開(kāi)始觸擊..");
};
interactionBehaviour.OnContactStay = () =>
{
// Debug.Log("保持觸擊..");
};
interactionBehaviour.OnContactEnd = () =>
{
Debug.Log("觸擊結(jié)束");
};
}
}
...
相關(guān)鏈接:
【Unity-Leap Motion】開(kāi)發(fā)一個(gè)最簡(jiǎn)單的Leap Motion程序——帶懸停、接觸和抓取事件