To facilitate Unity Editor native support for tracked controllers supported by OpenVR, the Unity VR subsystem presents VR controller inputs as separate joysticks. You can access their axis and button values with the UnityEngine.Input class.
By using OpenVR’s controller abstraction, the Unity Editor presents axis and button states in a hardware-agnostic approach (that is, it doesn’t refer to any specific hardware, but uses generic terms). However, for the sake of clarity, the axis and button mappings given below are for the two supported controller types: the HTC Vive controllers, and the Oculus Touch Controllers.
When properly configured and connected, a pair of Oculus Touch Controllers or a pair of HTC Vive controllers appear in the list returned by UnityEngine.Input.GetJoystickNames() as OpenVR Controller - Left and OpenVR Controller - Right. When available, these controllers appear highlighted in green in the SteamVR status window.
Unity script code can test for the availability of these controllers by periodically checking for their presence in the list of joystick names. When the controllers are turned off or have their batteries removed, an empty string replaces their name in the list returned by UnityEngine.Input.GetJoystickNames(). When the controllers are turned on again, their name appears in the list of returned joysticks.
Vive Controller Hardware Feature | Touch Controller Hardware Feature | 操作 | Unity Button ID | Unity Axis ID | Unity Axis 値の範囲 |
---|---|---|---|---|---|
Left Controller Menu Button (1) | Button.Three | 押す | 2 | ||
Right Controller Menu Button (1) | Button.One | 押す | 0 | ||
Left Controller Trackpad (2) | Button.PrimaryThumbstick | 押す | 8 | ||
Right Controller Trackpad (2) | Button.SecondaryThumbstick | 押す | 9 | ||
Left Controller Trackpad (2) | Button.PrimaryThumbstick | 接触 | 16 | ||
Right Controller Trackpad (2) | Button.SecondaryThumbstick | 接触 | 17 | ||
Left Controller Trackpad (2) | Axis2D.PrimaryThumbstick | 水平移動 | 1 | –1.0 から 1.0 | |
Left Controller Trackpad (2) | Axis2D.PrimaryThumbstick | 垂直移動 | 2 | –1.0 から 1.0 | |
Right Controller Trackpad (2) | Axis2D.SecondaryThumbstick | 水平移動 | 4 | –1.0 から 1.0 | |
Right Controller Trackpad (2) | Axis2D.SecondaryThumbstick | 垂直移動 | 5 | –1.0 から 1.0 | |
Left Controller Trigger (7) | Axis1D.PrimaryIndexTrigger | 接触 | 14 | ||
Right Controller Trigger (7) | Axis1D.SecondaryIndexTrigger | 接触 | 15 | ||
Left Controller Trigger (7) | Axis1D.PrimaryIndexTrigger | 握る | 9 | 0.0 から 1.0 | |
Right Controller Trigger (7) | Axis1D.SecondaryIndexTrigger | 握る | 10 | 0.0 から 1.0 | |
Left Controller Grip Button (8) | Axis1D.PrimaryHandTrigger | 握る | 11 | 0.0 から 1.0 | |
Right Controller Grip Button (8) | Axis1D.SecondaryHandTrigger | 握る | 12 | 0.0 から 1.0 |
ノート:
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.