Detecting Oculus HMD is removed

While running and with an Oculus HDM attached does anyone know of a way to detect if the user/player has removed the headset? I’m trying to setup a script to trigger rendering on screen instructions to the desktop display and then reload the scene once a new player puts the headset on to restart the experience in a multi user scenario.

@delphinius81 Posting your answer from Oculus Dev forums:

"You can register delegates for the HMDMounted and HMDUnmounted events through OVRManager.

OVRManager.HMDMounted += HandleHMDMounted;
OVRManager.HMDUnmounted += HandleHMDUnmounted;

void HandleHMDMounted() {
   // Do stuff
}

void HandleHMDUnmounted() {
   // Do stuff
}

Yesterday I was working on this issue and figured that HMD mount detection happens in OVRManager here:

if (!_wasHmdPresent && isHmdPresent)
		{
			try
			{
				if (HMDAcquired != null)
					HMDAcquired();
                        //Put here code that you want to run when the HMD is mounted.
			}`

And then the same goes for removal of the HMD:

	if (_wasUserPresent && !isUserPresent)
		{
			try
			{
				if (HMDUnmounted != null)
					HMDUnmounted();
                        //Put here code that you want to run when the HMD is unmounted.
			}

Has anyone succeeded in getting this to actually work?

I’ve tried this but doesn’t do anything. When the HMD is taken off, the screen goes black and Unity app suspends… I haven’t been able to run any code in response.

OVRManager.HMDUnmounted += OnHDUnmounted;

private void OnHDUnmounted()  {
	VRSettings.enabled = false;
	BackToMenu(); 	
}

This still does not work for me. See this question: Unity Oculus OVR not responding to remove/put on headset - Questions & Answers - Unity Discussions

I see the comment saying “enable run in background in player settings and inside OVRManager” - I’ve done so in Player Settings (and in code), but OVRManager lacks a “runInBackground” property… (see docs here: https://developer3.oculus.com/doc/1.18-unity/class_o_v_r_manager.html )