Windows Mixed Reality 运动控制器允许用户在混合现实应用程序中进行交互,从而允许在 Windows Mixed Reality 头盔的视野 (FOV) 内进行精确、低延迟的移动跟踪。这是使用头盔内置的传感器实现的。
为了在 Unity Editor 中实现对 Windows Mixed Reality 输入硬件的原生支持,Unity VR 子系统将三个输入作为单独的摇杆。使用 UnityEngine.Input 类来读取这些输入的轴和按钮值。
正确配置和连接到计算机后,运动控制器在 UnityEngine.Input.GetJoystickNames() 返回的列表中显示为 Spatial Controller - Left 和 Spatial Controller - Right。有关正确配置和连接运动控制器的信息,请参阅 Windows 开发人员中心文档。
在 Unity 中,可以通过脚本定期检查摇杆名称列表中是否存在这些控制器来检查其可用性。当控制器关闭或电池被移除时,UnityEngine.Input.GetJoystickNames() 返回的列表中的控制器名称将替换为空字符串。当控制器再次开启时,控制器名称将再次出现在列表中。
下图显示了 Windows Mixed Reality 控制器上可用的按钮。
下表显示了 Unity 中由控制器提供的每个输入的交互类型、按钮 ID、轴和值范围。
硬件功能 | 交互类型 | Unity 按钮 ID | Unity 轴 ID | Unity 轴值范围 |
---|---|---|---|---|
触控板 | 触控 | 左:18 右:19 |
- | - |
触控板 | 按压 | 左:16 右:17 |
- | - |
触控板 | 水平移动 | - | 左:17 右:19 |
–1.0 到 1.0 |
触控板 | 垂直移动 | - | 左:18 右:20 |
–1.0 到 1.0 |
控制棒 | 按压 | 左:8 右:9 |
- | - |
控制棒 | 水平移动 | - | 左:1 右:4 |
–1.0 到 1.0 |
控制棒 | 垂直移动 | - | 左:2 右:5 |
–1.0 到 1.0 |
选择触发器 | 按压 | 左:14 右:15 |
- | - |
选择触发器 | 挤压 | - | 左:9 右:10 |
0.0 到 1.0 |
握把按钮 | 按压 | 左:4 右:5 |
- | - |
握把按钮 | 挤压 | - | 左:11 右:12 |
0.0 和 1.0* |
菜单按钮 | 按压 | 左:6 右:7 |
- | - |
Unity 的 Windows Mixed Reality 控制器输入详细信息
*握把挤压轴是二进制控制装置,因此仅报告 0 或 1 的值,没有介于两者之间的值。
下表列出了使用 Window Mixed Reality 控制器输入时可用的不同轴以及每个轴的正负方向。
轴 | 位置方向 | 负方向 |
---|---|---|
水平 | 左 | 右 |
垂直 | 向上 | 向下 |
有关将 Windows MR 运动控制器与 Unity 结合使用的更多信息,请访问 Windows 开发人员中心关于 Unity 中的运动控制器 (Motion Controllers in Unity) 文档。
2017–11–21 页面已发布并进行了编辑审查
2017.2 版中的新功能
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.