Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
Anonymous's avatar
Anonymous
9 years ago

How can I detect when the users open and closes Oculus Home?

I would like to detect whether the users open Oculus Home such that I can allow my game to pause itself.

3 Replies

Replies have been turned off for this discussion
  • Anonymous's avatar
    Anonymous
    I ended up using this code to detect whether the user has Oculus Home open or not:

    public class OculusGlobalEventEmitter : MonoBehaviour {

    private bool? _isOculusHomeCurrentlyOpened;

    void Awake() {
    _isOculusHomeCurrentlyOpened = null;
    }

    void Update() {
    var isOculusHomeOpened = !OVRPlugin.hasVrFocus && OVRPlugin.userPresent;
    if (_isOculusHomeCurrentlyOpened != isOculusHomeOpened) {
    if (!isOculusHomeOpened) {
    Debug.Log("VR focus acquired!");
    } else {
    Debug.Log("VR focus lost!");
    }
    _isOculusHomeCurrentlyOpened = isOculusHomeOpened;
    }
    }
    }

    It detects whether the user is present (if the user is not present he/she cannot open Oculus Home) and if the user is present and the application has no Vr focus it


  • vrdaveb's avatar
    vrdaveb
    Oculus Staff
    I would like to detect whether the users open Oculus Home such that I can allow my game to pause itself.
    Unity automatically does this for you. They are working on re-enabling the "Run in Background" checkbox, but it currently has no effect and the app always pauses when Home or another app is focused. You can detect focus changes by subscribing to OVRManager.VrFocusAcquired/Lost. In general, you should not be directly using the internal OVRPlugin class. All functionality is exposed through the supported public classes such as OVRManager, OVRCameraRig, OVRDisplay, OVRTracker, and OVRInput.
  • owenwp's avatar
    owenwp
    Expert Protege
    It would be better if you could use the OnApplicationPaused and OnApplicationFocus script events.  They exist for this exact purpose, since the Oculus runtime works a lot like a mobile OS.