Unity3d SteamVR触摸板方向输入

Unity3d SteamVR触摸板方向输入,unity3d,steam,virtual-reality,Unity3d,Steam,Virtual Reality,我目前能够在我的Vive控制器上统一调用所有输入,除了触摸板的方向输入 如何访问用户按下的方向 下面是我一直试图使用的“EVRButtonId.k_EButton_DPad_Up”,但没有成功。我在.NET/C中对HTC VIVE API做了一些工作。我在pad上遇到了一些问题,因为我没有按下pad按钮就无法知道播放器是否在触摸pad,你会看到,当播放器没有触摸pad时,API会给出一个稍微随机的x,y位置,因为它是一个可触摸的pad 但是,如果玩家按下右键盘,请尝试此操作,它会给出键盘的x、y

我目前能够在我的Vive控制器上统一调用所有输入,除了触摸板的方向输入

如何访问用户按下的方向


下面是我一直试图使用的“EVRButtonId.k_EButton_DPad_Up”,但没有成功。

我在.NET/C中对HTC VIVE API做了一些工作。我在pad上遇到了一些问题,因为我没有按下pad按钮就无法知道播放器是否在触摸pad,你会看到,当播放器没有触摸pad时,API会给出一个稍微随机的x,y位置,因为它是一个可触摸的pad

但是,如果玩家按下右键盘,请尝试此操作,它会给出键盘的x、y位置:

//Get the right device
    rightDevice = SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.DeviceRelation.FarthestRight);

//Check if the device is valid
    if(rightDevice == -1){return Vector2.zero;}

//Get the x,y position on the pad
    Vector2 touch = SteamVR_Controller.Input(rightDevice).GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0);

    //Check if the player press on the pad button
if(!SteamVR_Controller.Input(deviceDroite).GetPress(SteamVR_Controller.ButtonMask.Touchpad)){return Vector2.zero}

    return touch;

我也有同样的问题。我规避这个问题的做法是:

    if(Controller.GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0)[0] > 0.8f
        && Controller.GetPressDown(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad))
    {
        // code continues...
    }
这似乎奏效了。基本上,我只是使用了这样一个事实,即我们知道何时按下键盘,我们知道用户在触摸键盘上的什么位置

这个特别的例子是在触摸板的右侧使用x轴(GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0)[0]。我不确定这是否是最好的方法,我可能对此表示怀疑,但它有效,目前没有太多帮助