Not launching in split screen some of the time

Hi
I am using XR manager and have this code on my VR scene:

public class VRTogglestart : MonoBehaviour
{
    public void Start()
    {
        StartXR();
    }
    public void StartXR()
    {
    
        XRGeneralSettings.Instance.Manager.InitializeLoaderSync();
        XRGeneralSettings.Instance.Manager.StartSubsystems();
    }
}

This works fine when I first open the app; I have a couple of 2d screens that I go through, then hit the launch button. Everything is fine.
If I then come out of the VR screen, using this code:

    void Start()
    {
        if (XRGeneralSettings.Instance.Manager.activeLoader != null)
        {
            XRGeneralSettings.Instance.Manager.activeLoader.Stop();
            XRGeneralSettings.Instance.Manager.activeLoader.Deinitialize();
            Debug.Log("XR stopped completely.");
        }
    }
}

So far so good.

But then when I hit the same launch button again to go back into VR mode, the scene loads but not as VR.

I have no idea where to start digging to work out what is happening. Can anyone help?

thanks

If you want to repeatedly start and stop the subsystem, don’t call to Deinitialize. You should generally just initialize once and deinitialize once. Then just call to StartSubsystems or StopSubsystems as needed in your code when you need to stop or restart VR mode.

oh wow - thank you
I have been trying to get this fixed for months
A huge result

@chris-massie
since I have commented out the Deinitialise line I have encountered problems with some of my buttons that I use to switch between 2D screens. They all work fine when that line is used: xrManager.DeinitializeLoader();

When it is commented out:
When I open my app, all buttons that I use to change between scenes, work fine.
I switch to my VR scene (using XR manager) and then go back to the same 2d screen
Only some of the buttons work

I have moved the buttons around on the screen and it is the button not the location
I have tried to rebuild the button but get the same result
I have tried copying a working button - if i don’t change any settings, the duplicate works
If I change the scene being called, the button then it stops working

I have tried looking at the logs but the button presses don’t appear to register in the console. I appreciate this isn’t much to go on but do you have any ideas? If not on how to fix, how to track down the bug in the console since nothing is appearing

What is my best approach to resolve this?
thanks

Considering this new information, could you raise a bug report for us? Unity QA: Building quality with passion