美文网首页unity练习
12_unity+LeapMotion

12_unity+LeapMotion

作者: alphonseLin | 来源:发表于2019-06-21 13:28 被阅读0次
game_view

安装方式

  1. 地址:
    https://developer.leapmotion.com/unity
    Core 包
    Leap Motion Interaction Engine 包
    其他包(如果你需要的话)
    安装界面

进入界面后

image.png
  1. 添加Trigger
    按照提示在 Input Manager 添加两个东西:
    -> Edit/Project Settings/Input/Axes,加两轴,
    一个 RightVRTriggerAxis,Axis 为 10th Joystick;
    另一个LeftVRTriggerAxis , Axis 为 9th Joystick:
添加Trigger界面
  1. 弄个小程序做测试
    添加个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("触击结束");
    };
}

}

...

相关链接:
【Unity-Leap Motion】开发一个最简单的Leap Motion程序——带悬停、接触和抓取事件

相关文章

  • 12_unity+LeapMotion

    安装方式 地址:https://developer.leapmotion.com/unityCore 包Leap ...

网友评论

    本文标题:12_unity+LeapMotion

    本文链接:https://www.haomeiwen.com/subject/fkjyqctx.html