c# - 如何从 Oculus Remote 获取输入?

标签 c# unity3d oculus

我想弄清楚如何在 Unity3D 5.3.4f 中使用 oculus Remote 。我找到了一些 documentation关于 OVR 映射,但我似乎无法弄清楚。

我想要实现的是单击中间按钮(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 remote controller unity,可以帮帮我吗?

谢谢,

约翰

最佳答案

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

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

关于c# - 如何从 Oculus Remote 获取输入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37000637/

相关文章:

c# - 二维区域中的未知字符

c# - 通过变换而不是 fov 使用鼠标滚轮放大/缩小相机?

performance - 为什么纹理查找比直接计算慢得多?

c# - 了解 System.Xml.Serialization.XmlIgnoreAttribute 与基类

c# - 确保部分连接的有向图是强连接的

Android Studio 无法找到 Oculus SDK

c++ - 如何检测插入/插入Oculus触摸 Controller ?

c# - AutoMapper 2.1.265 中缺少成员

c# - 使用基类在多个浏览器中运行 Selenium 测试

c# - 使用长时间运行的方法在 ASP.NET Web 窗体中阻止网页