接口,用于在 Unity Cluster 中读取和写入输入。
ClusterInput 通过连接 VRPN 服务器可提供对 VRPN 设备的访问。它还可提供对可写入输入的访问。ClusterInput 管理的所有输入都将复制到集群中其余已连接的从属设备。使用 ClusterInput 与使用 Unity 中的传统输入系统非常像。
using UnityEngine; using System.Collections;
public class ExampleClass : MonoBehaviour { void Update() { // Buttons and Axis provide a single value. bool buttonValue = ClusterInput.GetButton("button1"); float axisValue = ClusterInput.GetAxis("axis1");
// A tracker provides 2 values, rotation and position. Vector3 position = ClusterInput.GetTrackerPosition("tracker1"); Quaternion rotation = ClusterInput.GetTrackerRotation("tracker1");
if (ClusterNetwork.isMasterOfCluster) { float axisValueCustom = MyCustomDevicePlugin.GetValue("myaxis"); ClusterInput.SetAxis("customAxis", axisValueCustom); } } }
AddInput | 添加一个新的 VRPN 输入条目。 |
CheckConnectionToServer | 检查设备与相连 VRPN 服务器的连接状态。 |
EditInput | 编辑通过 ClusterInput.AddInput 添加的输入条目。 |
GetAxis | 以连续 float 的形式返回轴值。 |
GetButton | 返回按钮的二进制值。 |
GetTrackerPosition | 以 Vector3 的形式返回跟踪器的位置。 |
GetTrackerRotation | 以四元数的形式返回跟踪器的旋转。 |
SetAxis | 设置此输入的轴值。仅对输入键入的 Custom 有效。 |
SetButton | 设置此输入的按钮值。仅对输入键入的 Custom 有效。 |
SetTrackerPosition | 设置此输入的跟踪器位置。仅对输入键入的 Custom 有效。 |
SetTrackerRotation | 设置此输入的跟踪器旋转。仅对输入键入的 Custom 有效。 |
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.