unity-game-enginegoogle-cardboard

Please initialize Cardboard XR loader before calling this function


I followed the quickstart from google cardboard VR, everything is ok & I can build it to android. But if I play in unity, the console shows an error "Please initialize Cardboard XR loader before calling this function."

Please initialize the Cardboard XR loader before calling this function.
UnityEngine.Debug:LogError (object)
Google.XR.Cardboard.Api:UpdateScreenParams () (at Library/PackageCache/com.google.xr.cardboard@09d53ca94c/Runtime/Api.cs:295)
CardboardStartup:Update () (at Assets/Samples/Google Cardboard XR Plugin for Unity/1.12.0/Hello Cardboard/Scripts/CardboardStartup.cs:71)

im using Unity 2020.3.27f1 and cardboard version 1.12.0

error screenshot


Solution

  • Open CardboardStartup.cs, find Api.UpdateScreenParams(); at the bottom (around line 70) and add the conditions to be like this, and see if it works :

    #if !UNITY_EDITOR
            Api.UpdateScreenParams();
    #endif