SteamVR Plugin 2.x.x概述

作者:追风剑情 发布于:2019-3-25 19:53 分类:Unity3d

SteamVR Unity Plugin文档
https://valvesoftware.github.io/steamvr_unity_plugin/

22.png

事件配置
Window->SteamVR Input

11111.png

示例:当GameObject挂上以下脚本,便可处理相应的Action

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Valve.VR;

[RequireComponent(typeof(SteamVR_TrackedObject))]
public class TestThrow : MonoBehaviour
{
    //获取输入Action: InteractUI
    //可通过SteamVR Input窗口查看和编辑所有Action
    public SteamVR_Action_Boolean spawn = SteamVR_Input.GetAction<SteamVR_Action_Boolean>("InteractUI");

    //SteamVR_Behaviour_Pose负责跟踪设备行为
    SteamVR_Behaviour_Pose trackedObj;

    private void Awake()
    {
        trackedObj = GetComponent<SteamVR_Behaviour_Pose>();
    }

    private void FixedUpdate()
    {
        //按下
        if (spawn.GetStateDown(trackedObj.inputSource))
        {

        }
        //释放
        else if (spawn.GetStateUp(trackedObj.inputSource))
        {

        }
    }
}


标签: SteamVR Plugin

Powered by emlog  蜀ICP备18021003号   sitemap

川公网安备 51019002001593号