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’ (Hướng dẫn nhanh về Google Cardboard dành cho Unity | Google for Developers) and
‘End-user documentation’ (About the XR Plug-in Management package | XR Plugin Management | 3.2.17).
But using the given code from the ‘End-user documentation’ doesn’t work.
private void Start() {
StartCoroutine(StartXR2());
}
public IEnumerator StartXR2()
{
Debug.Log("Initializing XR...");
yield return XRGeneralSettings.Instance.Manager.InitializeLoader();
if (XRGeneralSettings.Instance.Manager.activeLoader == null)
{
Debug.LogError("Initializing XR Failed. Check Editor or Player log for details.");
}
else
{
Debug.Log("Starting XR...");
XRGeneralSettings.Instance.Manager.StartSubsystems();
}
}
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:
private void Start() {
xRGeneralSettings = XRGeneralSettings.CreateInstance<XRGeneralSettings>();
xRGeneralSettings.Manager = XRManagerSettings.CreateInstance<XRManagerSettings>();
StartCoroutine(StartXR());
}
public IEnumerator StartXR()
{
Debug.Log("Initializing XR...");
yield return xRGeneralSettings.Manager.InitializeLoader();
while(!xRGeneralSettings.Manager.isInitializationComplete){
Debug.Log("Still initializing XR");
yield return new WaitForSeconds(0.5f);
}
if (xRGeneralSettings.Manager.activeLoader == null)
{
Debug.LogError("Initializing XR Failed. Check Editor or Player log for details.");
}
else
{
Debug.Log("Starting XR...");
xRGeneralSettings.Manager.StartSubsystems();
vractive = true;
}
}
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:
using UnityEditor.XR.Management.Metadata;
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