SteamVR 2.3.2 获取手柄按键状态

 

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

public class InputController : MonoBehaviour
{
    // Start is called before the first frame update

    public Hand hand;
  
    // Start is called before the first frame update
    void Start()
    {

    }

    private void OnEnable()
    {
        if (hand == null)
        {
            hand = this.GetComponent<Hand>();
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (SteamVR_Input.GetState("default", "interactUI", hand.handType))
        {

            Debug.Log("interactUI");
        }
        //自定义按键
        if (SteamVR_Input.GetState("custom", "RayHide", hand.handType))
        {
            Debug.Log("RayHide");
        }

        if (SteamVR_Input.GetState("custom", "TouchPad", hand.handType))
        {
            Debug.Log("TouchPad");
        }

    }

}
©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页