The reason for writing this article is mainly because the virtual reality is very popular now, but the mainstream virtual reality device (HTC VIVE) Tutorial is less pitiful, this I have deep experience. therefore, I would like to develop in my usual problems and solutions to record down, share to everyone, if there is any mistake or what better plan we also please point out that we learn from each other, Haha.
okay, just on the Code.
Using unityengine;using System.collections;public class Shoubingkongzhi:monobehaviour {////////Ste Amvr_trackedobject tracked; void Awake () {//get handle tracked = Getcomponent<steamvr_trackedobject> (); }//Update is called once per frame void fixedupdate () {var device = steamvr_controller.input ((int.) track ed.index); If (device. Getpressdown (STEAMVR_CONTROLLER.BUTTONMASK.TOUCHPAD)) {Debug.Log ("press the disc"); } else if (device. Getpressdown (SteamVR_Controller.ButtonMask.Trigger)) {Debug.Log ("press the trigger"); } else if (device. Getpressdown (SteamVR_Controller.ButtonMask.Grip)) {Debug.Log ("press the handle side key"); } else if (device. Getpressdown (SteamVR_Controller.ButtonMask.ApplicationMenu)) {Debug.Log ("press the handle menu key"); } else if (device. Getpressdown (SteamVR_Controller.ButtonMask.ApplicationMenu)) {Debug.Log ("press the handle menu key"); } }}
Debug.Log ("press the handle menu key");}}}
These are the key presses in the HTC Vive Handle. Others are:
Press the key to Release-device. Getpressup (SteamVR_Controller.ButtonMask.Trigger);
Press the key Changan-device. Getpress (SteamVR_Controller.ButtonMask.Trigger);
There is another way to press the button, but I feel very awkward with myself, not as good as the Above. Device. Gettouchdown (SteamVR_Controller.ButtonMask.ApplicationMenu);
Other usages are similar to Getpressdown ().
Reprinted from: http://www.52vr.com/article-391-1.html
Developing HTC Vive--joystick Controls with Unity