Forum Discussion
bakno
10 years agoExplorer
Universal menu integration
We are building a Rift game and found that we need to integrate it with the UM.
How can we know when the UM is active?
And how can we know if the user selected the Recenter App option?
Thanks
Andres
How can we know when the UM is active?
And how can we know if the user selected the Recenter App option?
Thanks
Andres
21 Replies
Replies have been turned off for this discussion
- vrdavebOculus StaffThere isn't a way to know that the UM specifically is active, but you can detect the app has lost focus using OVRManager.hasVrFocus. You can detect that the app has been recentered by adding a handler to OVRDisplay.RecenteredPose
- baknoExplorerThank you
- moodlemanProtegeYes!!!! @vrdaveb !!!! I've been looking for this recenter option from universal menu for a long time!
But, I can't find how to implement that from Unity, I've found:
OVRManager.display.RecenteredPose, which is a System.Action that "Occurs when the head pose is reset"... But really don't know how to use it (I'm quite new to Unity).
How can I "add a handler" to that???? - vrdavebOculus StaffOVRManager.display.RecenteredPose += () => { /** Your code here. **/ };
- moodlemanProtegeThanks @vrdaveb, I've tried that code, and tried also with this syntax:
But I can't get the callback from the recenter option from the Universal menu. That seems to execute when I recenter the HMD from my own code, but not from the UM :(OVRManager.display.RecenteredPose += delegate () { /** My code here. **/ };
I'm starting to think I'm doing something really wrong, as this should work automatically in Unity, or be easy enough to be documented anywhere in the net, but... I can't find anything. And all Oculus programs I tried work well, but mine just doesn't do anything.
Anyone knows what do you need to do in Unity to recenter the HMD when called from the oculus Universal Menu????
Thanks! - baknoExplorerCalling OVRManager.hasVrFocus is always true. How do you integrate the OVR Plugin in Unity to make it work?
We are using Unity 5.4 which is not supposed to need the OVR Plugin. But neither OnApplicationFocus or OnApplicationPause are called when the UM is activated or deactivated. - vrdavebOculus Staff> How do you integrate the OVR Plugin in Unity to make it work?
OVRPlugin is an internal API that you should not be using directly.
> I can't get the callback from the recenter option from the Universal menu.
> neither OnApplicationFocus or OnApplicationPause are called when the UM is activated or deactivated.
These both sound like bugs. We'll investigate and let you know if there is a fix or workaround soon. - vrdavebOculus StaffHave you enabled Run in Background in Player Settings? If not, please do.
- moodlemanProtegeHi @vrdaveb, and thanks!
I didn't have that option enabled, I've enbled it and try... but nothing happens: from the app, I go to the Universal menu, select recenter, look and press "A", and it returns to the game, but no recentering at all :(
Do I have to code something to make it work? I'm only binding the xbox back button to recenter the HMD manually with this:
That works OK when I press the back button.if (Input.GetButtonDown("Recenter"))
{
OVRManager.display.RecenterPose();
Debug.Log("Recentering view... OK");
}
In case it helps, I find it curious that when it comes back to the game after pressing A for recentering, it doesn't recenter, but I get the A button event and the game reacts to it (the player jumps!). Perhaps it shouldn't capture it?
Thanks! - vrdavebOculus StaffI can't reproduce these issues. Can you try throwing this script onto a GameObject in your scene and sending me the output_log.txt?
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;
public class EventTester : MonoBehaviour
{
public Text text;
int logLength = 8;
Queue<string> logBuffer = new Queue<string>();
void Start()
{
OVRManager.HMDAcquired += () => Log("HMDAcquired");
OVRManager.HMDLost += () => Log("HMDLost");
OVRManager.HMDMounted += () => Log("HMDMounted");
OVRManager.HMDUnmounted += () => Log("HMDUnmounted");
OVRManager.VrFocusAcquired += () => Log("VrFocusAcquired");
OVRManager.VrFocusLost += () => Log("VrFocusLost");
OVRManager.AudioOutChanged += () => Log("AudioOutChanged");
OVRManager.AudioInChanged += () => Log("AudioInChanged");
OVRManager.TrackingAcquired += () => Log("TrackingAcquired");
OVRManager.display.RecenteredPose += () => Log("RecenteredPose");
}
void OnApplicationQuit()
{
Log("OnApplicationQuit");
}
void OnApplicationPause()
{
Log("OnApplicationPause");
}
void Log(string message)
{
if (text != null) {
logBuffer.Enqueue(message);
while (logBuffer.Count > logLength)
logBuffer.Dequeue();
text.text = string.Join("\n", logBuffer.ToArray());
}
else
{
Debug.Log (message);
}
}
}
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
- 3 months ago
- 3 months ago