I have a 2020.3 project and I have Initialize XR on Startup in Project Settings set to false because I want to manually start VR. Then, in my input monobehaviour Awake I write:
The problem was that there was a warning I wasn’t seeing: “XR Management has already initialized an active loader in this scene.Please make sure to stop all subsystems and deinitialize the active loader before initializing a new one.”
And this did not allow me to use VR. This shouldn’t be a warning, it should be an error as everything continues on as active but without functionality.
The fix was to StopSubsystems and Deinitialize the active loader BEFORE initializing it. This should be an addendum to everyone else who Googled a fix for manually initializing OpenXR:
public void Awake(){
//fix
if( XRGeneralSettings.Instance.Manager.activeLoader != null ){
XRGeneralSettings.Instance.Manager.StopSubsystems();
XRGeneralSettings.Instance.Manager.DeinitializeLoader();
}
XRGeneralSettings.Instance.Manager.InitializeLoaderSync();
XRGeneralSettings.Instance.Manager.StartSubsystems();
var actions = new InputActions();
actions.Enable();
actions.vrControls.leftAnalogPos.performed += ctx => Debug.LogError( ctx.ReadValue<Vector2>() );
}
Think there is something more going on here, because i’m having the same issue the OG poster is describing.
If you uncheck Initialize XR on Startup, enter play mode then start the loader manually in code
Stop Play mode
Start play mode again - it automatically loads the first loader in the list.
Re-enable Initialize XR on Startup and enter play mode
Immediately receive the following error - clearly it’s trying to load it twice “automatically”
XR Management has already initialized an active loader in this scene.Please make sure to stop all subsystems and deinitialize the active loader before initializing a new one.
UnityEngine.XR.Management.XRGeneralSettings:AttemptInitializeXRSDKOnLoad () (at Library/PackageCache/com.unity.xr.management@4.0.1/Runtime/XRGeneralSettings.cs:148)
It’s almost as if the loader from the previous play mode is still “active”. Which sounds strange, but nothing else makes sense.
Definitely a XR Plugin Management issue. Not OpenXR, because I’m only testing manually loading of the Oculus plugin right now.
Unity 2020.3
XR Plugin Management 4.0.1
Edit: Tested in 2019.4.20 and has the same behaviour.
THANK YOU. I wasn’t even initiatizing XR in script, but since upgrading to Unity 2019.4 I was suddenly only able to run VR in playmode once. This fixed me.
Still a problem in 2021.3.31. I have 2 separate unity projects, one where this occurs and one where it doesn’t, trying to track down the difference but no luck and can’t seem to figure out why one is initializing a loader before my code tells it to with the “Initialize XR on Startup” unchecked…
I had the same problem after setting up a basic scene with an XR Rig on Unity 2022.3.13f1 with automatic XR Loading
The play mode only worked once in VR (using Quest Link) and then I had to restart Unity for it to work again
Still broken. Delete temp, lib, vs and obj if you want. Alternatively throw this script in somewhere at the start or in a developer tool until you isolate where you start loader. Same as the one above
public void Awake() {
// Fix: Stop subsystems and deinitialize the loader if it's already active
if (XRGeneralSettings.Instance.Manager.activeLoader != null) {
XRGeneralSettings.Instance.Manager.StopSubsystems();
XRGeneralSettings.Instance.Manager.DeinitializeLoader();
}
// Initialize and start the loader
XRGeneralSettings.Instance.Manager.InitializeLoaderSync();
XRGeneralSettings.Instance.Manager.StartSubsystems();
}