if (InputDevices.GetDeviceAtXRNode(XRNode.RightHand).TryGetFeatureValue(CommonUsages.primary2DAxis, out Vector2 primary2DAxis))
{
if (primary2DAxis.magnitude > 0)
{
// 根据轴的值判断摇杆朝向
if (primary2DAxis.y < 0)
{
// 摇杆朝下
ShowLog("摇杆朝下");
}
else if (primary2DAxis.y > 0)
{
// 摇杆朝上
ShowLog("摇杆朝上");
}
else if (primary2DAxis.x < 0)
{
// 摇杆朝左
ShowLog("摇杆朝左");
}
else if (primary2DAxis.x > 0)
{
// 摇杆朝右
ShowLog("摇杆朝右");
}
}
}
02-02
390
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
02-24
2703
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
01-04
1332
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
05-26
1449
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)