Search Unity

Question Not launching in split screen some of the time

Discussion in 'XR Interaction Toolkit and Input' started by lz7cjc, Mar 12, 2021.

  1. lz7cjc

    lz7cjc

    Joined:
    Sep 10, 2019
    Posts:
    540
    Hi
    I am using XR manager and have this code on my VR scene:
    Code (CSharp):
    1. public class VRTogglestart : MonoBehaviour
    2. {
    3.     public void Start()
    4.     {
    5.         StartXR();
    6.     }
    7.     public void StartXR()
    8.     {
    9.    
    10.         XRGeneralSettings.Instance.Manager.InitializeLoaderSync();
    11.         XRGeneralSettings.Instance.Manager.StartSubsystems();
    12.     }
    13. }
    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:
    Code (CSharp):
    1.     void Start()
    2.     {
    3.         if (XRGeneralSettings.Instance.Manager.activeLoader != null)
    4.         {
    5.             XRGeneralSettings.Instance.Manager.activeLoader.Stop();
    6.             XRGeneralSettings.Instance.Manager.activeLoader.Deinitialize();
    7.             Debug.Log("XR stopped completely.");
    8.         }
    9.     }
    10. }
    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
     
  2. chris-massie

    chris-massie

    Unity Technologies

    Joined:
    Jun 23, 2020
    Posts:
    231
    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.
     
  3. lz7cjc

    lz7cjc

    Joined:
    Sep 10, 2019
    Posts:
    540
    oh wow - thank you
    I have been trying to get this fixed for months
    A huge result
     
  4. lz7cjc

    lz7cjc

    Joined:
    Sep 10, 2019
    Posts:
    540
    @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
     
  5. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,822