1、下载VRtk插件直接将带的场景里的这四个复制到你想要的场景里
2、如果不用这个插件就要下载一个steamVR插件将其中的steamVR拖入场景中作为头盔相机之后写代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class VRcotroller : MonoBehaviour {
public SteamVR_TrackedObject trackedObject;//头盔
// Use this for initialization
void Start () {
trackedObject = transform.GetComponent<SteamVR_TrackedObject>();
}
// Update is called once per frame
void Update () {
}
void OnTriggerStay(Collider other)
{
//判断触发的按键为哪个
SteamVR_Controller.Device device = SteamVR_Controller.Input((int)trackedObject.index);
if(device.GetHairTriggerDown())
{
}
}
}