Skip to main content
April 12, 2016

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.
This topic has been closed for replies.

3 replies

April 12, 2016
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


Inspiring
April 12, 2016
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.
Up and Coming
April 12, 2016
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.