Welcome to the Oculus Developer Forums!

Your participation on the forum is subject to the Oculus Code of Conduct.

In general, please be respectful and kind. If you violate the Oculus Code of Conduct, your access to the developer forums may be revoked at the discretion of Oculus staff.

GearVR Controller in editor

dakomdakom Posts: 7
NerveGear
I'm having trouble getting the GearVR controller to work in the Unity Editor.

Here's my basic script (attached to a simple GameObject):
```
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
public class Wand : MonoBehaviour {
    void Update() {
        transform.rotation = OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTrackedRemote);
    }

/* ALTERNATIVE:
    public Transform controller;
   
    public static bool leftHanded { get; private set; }
 
    void Awake() {
        #if UNITY_EDITOR
        leftHanded = false;        // (whichever you want to test here)
        #else
        leftHanded = OVRInput.GetControllerPositionTracked(OVRInput.Controller.LTouch);
        #endif
    }
 
    void Update() {

        OVRInput.Controller c = leftHanded ? OVRInput.Controller.LTouch : OVRInput.Controller.RTouch;
        if (OVRInput.GetControllerPositionTracked(c)) {
            controller.localRotation = OVRInput.GetLocalControllerRotation(c);
            controller.localPosition = OVRInput.GetLocalControllerPosition(c);
        }
    }  
    */
}
```

Unity Editor log:



Note that the Unity Editor says "Virtual Reality SDK Oculus failed to initialize." as a warning, though I think that makes sense since there's no Rift or native windows VR device connected

I've dragged the OVRCameraRig prefab into the scene, and can emulate that by holding control and moving the mouse

I've connected my GearVR controller via bluetooth

Added the Oculus ID to settings

Created a sig file and added it to the project

Help please :)

Comments

  • dakomdakom Posts: 7
    NerveGear
    Also - UnityEngine.Input.GetJoystickNames(); returns an empty list
Sign In or Register to comment.