标签:
怎么安装设备,配置环境我就不说了,自行百度,教程很多也很简单。接下来说下Vive手柄的控制。
手柄是HTC Vive的重要交互手段,我们通过第一个图片应该对其有一个直观的了解了,总共是九个按钮:
using UnityEngine; using System.Collections; /// <summary> /// 扳机控制触发事件 /// </summary> public class ComfirmController : MonoBehaviour { //手柄 SteamVR_TrackedObject trackedObj; void Awake() { //获取手柄脚本组件 trackedObj = GetComponent<SteamVR_TrackedObject> (); } // Use this for initialization void Start () { } // Update is called once per frame void FixedUpdate () { //获取手柄输入 var device = SteamVR_Controller.Input ((int)trackedObj.index); //此处可以换其他的函数触发GetPress/GetTouch /GetPressUp GetTouchDown/GetTouchUp/GetAxis if (device.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad)) { Debug.Log("按下圆盘"); } else if (device.GetPressDown(SteamVR_Controller.ButtonMask.Trigger)) { Debug.Log("按下扳机键"); } else if (device.GetPressDown(SteamVR_Controller.ButtonMask.Grip)) { Debug.Log("按下手柄侧键"); } else if (device.GetPressDown(SteamVR_Controller.ButtonMask.ApplicationMenu)) { Debug.Log("按下手柄菜单键"); } else if (device.GetPressDown(SteamVR_Controller.ButtonMask.ApplicationMenu)) { Debug.Log("按下手柄菜单键"); } } }
标签:
原文地址:http://www.cnblogs.com/unity3ds/p/5908592.html