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

Joh*_*han 5 c# unity-game-engine oculus

我试图弄清楚如何在Unity3D 5.3.4f中使用oculus遥控器。我已经找到了一些 有关OVR映射的文档,但似乎无法弄清楚。

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

我现在使用的是这一行代码

if (OVRInput.GetUp(OVRInput.Button.One))
    {
        Debug.Log("remote click");
    }
Run Code Online (Sandbox Code Playgroud)

但是,当我运行该应用程序时,出现此错误。

NullReferenceException:对象引用未设置为对象OVRInput.GetUp(按钮virtualMask,控制器controllerMask)的实例(在Assets / OVR / Scripts / OVRInput.cs:600上)menuButtonHandler.Update()(在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);
}
Run Code Online (Sandbox Code Playgroud)

有没有人曾经团结过Oculus遥控器,可以帮助我吗?

谢谢,

约翰

小智 1

在调用 GetUp() 之前,可能需要初始化该方法中的对象之一。

仔细查看您的初始化代码以及您可能拥有的任何示例——我敢打赌,在不仔细查看之后您会发现缺少一些东西。我不熟悉 Unity API,但如果它们是类似于 PC 或移动 C++ API 的东西,那么您很可能错过了一个步骤,或者忘记启动 VR 服务。