c# – 如何从Oculus遥控器获取输入?

我试图弄清楚如何在Unity3D 5.3.4f中使用oculus远程.我发现了一些关于OVR映射的
documentation,但我似乎无法弄明白.

我想要实现的是点击中间按钮(Button.One).

我现在使用的是这行代码

if (OVRInput.GetUp(OVRInput.Button.One))
    {
        Debug.Log("remote click");
    }

但是当我运行应用程序时,我得到了这个错误.

NullReferenceException: Object reference not set to an instance of an object
OVRInput.GetUp (Button virtualMask, Controller controllerMask) (at Assets/OVR/Scripts/OVRInput.cs:600)
menuButtonHandler.Update () (at Assets/menuButtonHandler.cs:136)

哪个可以在这个脚本中找到

/// <summary>
/// Gets the current up state of the given virtual button mask with the given controller mask.
/// Returns true if any masked button was released this frame on any masked controller and no other masked button is still down this frame.
/// </summary>
public static bool GetUp(Button virtualMask, Controller controllerMask = Controller.Active)
{
    return OVRManager.input.GetResolvedButtonUp(virtualMask, RawButton.None, controllerMask);
}

在团结之前有没有人习惯Oculus遥控器可以帮助我?

谢谢,

约翰

最佳答案 在进行GetUp()调用之前,可能需要初始化该方法中的一个对象.

仔细看看你的初始化代码,以及你可能拥有的任何样本 – 我打赌你会在没有太多看之后找到遗漏的东西.我不熟悉Unity API,但如果它们类似于PC或移动C API,那么您可能错过了一步,或者忘记启动VR服务.

点赞