Hi guys, I’ve been looking for a solution but I haven’t found it. I am desperate.
I’m developing a windows application with OpenXR: when I take off the Oculus a scene is loaded with a video. The problem is that both in the Editor and in the build there is a huge lag (even if the scene is empty) when the Oculus is not worn.
Run in background is checked.
I have enabled OculusXR Feature and this is the script that allows to recognize if the headset is worn or not:
using UnityEditor;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.XR.OpenXR.Features;
#if UNITY_EDITOR
[UnityEditor.XR.OpenXR.Features.OpenXRFeature(UiName = "VR State Tracking",
BuildTargetGroups = new[] { BuildTargetGroup.WSA, BuildTargetGroup.Standalone, BuildTargetGroup.Android },
Company = "Your Company",
Desc = "Tracks state changes.",
Version = "0.0.1",
FeatureId = featureId)]
#endif
public class MyOwnXRFeature : OpenXRFeature
{
public const string featureId = "com.yourcompany.features.statetracking";
// This is to change a number of state changes in a very granular way:
protected override void OnSessionStateChange(int oldState, int newState)
{
Debug.Log($"OnSessionStateChange: {oldState} -> {newState}");
}
// This will happen when headset put on:
protected override void OnSessionBegin(ulong xrSession)
{
Debug.Log($"Feature OnSessionBegin: {xrSession}");
Debug.Log("Put on");
SceneManager.LoadScene("Dashboard 2");
}
// This will happen when headset taken off:
protected override void OnSessionEnd(ulong xrSession)
{
Debug.Log($"eatureOnSessionEnd: {xrSession}");
Debug.Log("Put off");
SceneManager.LoadScene("Videoloop");
}
}
Is this lag an OpenXR problem?
Because with OVRManager I didn’t have this problem, but the HDMMounted/HDMUnmounted events didn’t work (they only worked in the editor). I can use OVRManager if you know a way to make it works in build.
I use:
Unity 2021.3.0f1
Quest 2 & Quest Pro
Thank you for your time, and sorry for my English!