How can I get input from the Oculus remote?

I am trying to figure out how to use oculus remote in Unity3D 5.3.4f. I found documentation about OVR mapping, but I can't figure out how to do this.

I want to reach when the middle button (Button.One) is pressed.

Now i use this line of code

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

But when I run the application, I get this error.

NullReferenceException: the reference to the object is not installed in the object instance OVRInput.GetUp (Button virtualMask, ControllerMaskMask) (in Assets / OVR / Scripts / OVRInput.cs: 600) menuButtonHandler.Update () (at Assets / menuButtonHandler.cs: 136)

What can be found in this script

/// <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);
}

Has anyone used Oculus for remote control before in unity and can help me?

Thank,

Johan

+4
2

, , , GetUp().

, - , - . API- Unity, - API ++, , - VR.

+1

Unity Version 2017.1.1, "Oculus Utilities for Unity"

Oculus Utilities Unity

Unity, : - "Asset" → "Import package" → " " - Oculus Utility package

"Oculus Utilities download" enter image description here

"OVRInput.update()" .

void Update ()
    {
        OVRInput.Update(); // Call before checking the input

        if (OVRInput.Get(OVRInput.Button.DpadLeft)) {
            print("left button pressed");
        }
        if (OVRInput.Get(OVRInput.Button.DpadRight)) {
            print("right button pressed");
        }
        if (OVRInput.Get(OVRInput.Button.One)) {
            print("round button pressed");
        }
    }

OVRInput

OVRInput

0

All Articles