Search Unity

Resolved Unable to start Cardboard modus via script with XR Plug-in Management

Discussion in 'VR' started by Imsimity-MZ, Nov 18, 2020.

Thread Status:
Not open for further replies.
  1. Imsimity-MZ

    Imsimity-MZ

    Joined:
    Jul 12, 2016
    Posts:
    5
    Hello,

    I've got an application which uses Google Cardboard and it has to get updated to the "new" Google Cardboard plugin which uses the "new" XR Plugin Management.
    In this app it switches between 2D and Cardboard. Therefore two cameras are used which are en-/disabled.
    Because my first attempts didn't work I created a new project for testing.
    Only cardboard with its sample is in it.
    Starting the sample with the 'Initialize XR on Startup' enabled (in XR Plug-in Management) works fine (on android mobile device).
    But I want to enable cardboard via code therefore I disabled it.

    I read through the
    'Quickstart for Google Cardboard for Unity' (https://developers.google.com/cardboard/develop/unity/quickstart) and
    'End-user documentation' (https://docs.unity3d.com/Packages/com.unity.xr.management@3.2/manual/index.html).
    But using the given code from the 'End-user documentation' doesn't work.
    Code (CSharp):
    1.     private void Start() {
    2.         StartCoroutine(StartXR2());
    3.     }
    4.     public IEnumerator StartXR2()
    5.     {
    6.         Debug.Log("Initializing XR...");
    7.         yield return XRGeneralSettings.Instance.Manager.InitializeLoader();
    8.  
    9.         if (XRGeneralSettings.Instance.Manager.activeLoader == null)
    10.         {
    11.             Debug.LogError("Initializing XR Failed. Check Editor or Player log for details.");
    12.         }
    13.         else
    14.         {
    15.             Debug.Log("Starting XR...");
    16.             XRGeneralSettings.Instance.Manager.StartSubsystems();
    17.         }
    18.     }
    It throws the Error 'Initializing XR Failed. Check Editor or Player log for details.'
    In the Editor Log I can find a list of
    Fallback handler could not load library F:/Programme/Unities/2020.1.12f1/Editor/Data/Mono/lib/cardboard_api'.
    Fallback handler could not load library F:/Programme/Unities/2020.1.12f1/Editor/Data/Mono/lib/cardboard_api.dll
    Fallback handler could not load library F:/Programme/Unities/2020.1.12f1/Editor/Data/Mono/lib/cardboard_api
    ...


    I also tried to create my own instance of the settings manager:
    Code (CSharp):
    1.     private void Start() {
    2.         xRGeneralSettings = XRGeneralSettings.CreateInstance<XRGeneralSettings>();
    3.         xRGeneralSettings.Manager = XRManagerSettings.CreateInstance<XRManagerSettings>();
    4.         StartCoroutine(StartXR());
    5.     }
    6.  
    7.  
    8.     public IEnumerator StartXR()
    9.     {
    10.         Debug.Log("Initializing XR...");
    11.         yield return xRGeneralSettings.Manager.InitializeLoader();
    12.  
    13.         while(!xRGeneralSettings.Manager.isInitializationComplete){
    14.             Debug.Log("Still initializing XR");
    15.             yield return new WaitForSeconds(0.5f);
    16.         }
    17.  
    18.         if (xRGeneralSettings.Manager.activeLoader == null)
    19.         {
    20.             Debug.LogError("Initializing XR Failed. Check Editor or Player log for details.");
    21.         }
    22.         else
    23.         {
    24.             Debug.Log("Starting XR...");
    25.             xRGeneralSettings.Manager.StartSubsystems();
    26.             vractive = true;
    27.         }
    28.     }
    but it's "spamming" 'Still initializing XR' every half a second. Without the while loop it throws the same error as described ('Initializing XR Failed...')

    Using the 'StopXR()' function doesn't throw any errors but with 'Initialize XR on Startup' enabled it doesn't stop the VR (on android mobile device).

    I also checked the 'Example: Accessing custom settings' part of the documentation and I think or rather it seems that I have to add this. But where and how?
    Using it as code has some issues:
    Example:
    Code (CSharp):
    1. using UnityEditor.XR.Management.Metadata;
    2. var metadata = XRPackageMetadataStore.GetMetadataForPackage(my_pacakge_id);
    Brings error 'error CS0117: 'XRPackageMetadataStore' does not contain a definition for 'GetMetadataForPackage''

    If that's the way to go is there any help to implement the given example code with the cardboard stuff?
    I'm really lost and couldn't find a real clue how to implement this.

    In other posts the initializing seems to work and the described issues seem to be different.
    I cannot go on without an understanding how to en-/disabling specific VR plugins.

    For my tests I'm currently using
    Unity 2020.1.12f1
    XR Plugin Management 3.2.16
    Google Cardboard XR Plugin for Unity 1.3.0
    Build Settings: Android

    If there is any other post about this issue (or bug description) I was obviously too stupid to find it and I'm sorry...

    Thank you for your help in advance
     
  2. Shaunyowns

    Shaunyowns

    Joined:
    Nov 4, 2019
    Posts:
    328
    Google Cardboard is no longer directly supported by Unity. If you have any issues related to Google's latest Cardboard XR plugin for Unity, the Google team has requested you open issues on Github here where their team will address.

    I'll resolve this!
     
Thread Status:
Not open for further replies.