Forum Discussion
Anonymous
9 years agoHow 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
- AnonymousI 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
- vrdavebOculus 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. - owenwpExpert ProtegeIt 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.
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 9 years ago
- 2 years ago
- 1 year agoAnonymous