"We offer new support options and therefor the forums are now in read-only mode! Please check out our Support Center for more information." - Vuforia Engine Team

Vuforia crashes after re-entering AR scene.

Greeting, I having some issues that when I re-enter AR scene again, it gave me this error. and the camera is off. And I'm using "create Instant Image Targets at Runtime from a file" method. Did anyone have this issue before? This is the error:-

Exception in callback: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> UnityEngine.MissingReferenceException: The object of type 'SetupImageTarget' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object.   at (wrapper managed-to-native) UnityEngine.MonoBehaviour.IsObjectMonoBehaviour(UnityEngine.Object)   at UnityEngine.MonoBehaviour.StartCoroutine (System.Collections.IEnumerator routine) [0x00014] in <58a34b0a618d424bb5fc18bb9bcdac20>:0   at SetupImageTarget.CreateImageTargetFromSideloadedTexture () [0x0005f] in D:\UnityProject\PopulAR_Dummy - Backup - v2\Assets\SetupImageTarget.cs:76   at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)   at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <437ba245d8404784b9fbab9b439ac908>:0    --- End of inner exception stack trace ---   at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00048] in <437ba245d8404784b9fbab9b439ac908>:0   at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <437ba245d8404784b9fbab9b439ac908>:0   at System.Delegate.DynamicInvokeImpl (System.Object[] args) [0x000e7] in <437ba245d8404784b9fbab9b439ac908>:0   at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args) [0x00008] in <437ba245d8404784b9fbab9b439ac908>:0   at System.Delegate.DynamicInvoke (System.Object[] args) [0x00000] in <437ba245d8404784b9fbab9b439ac908>:0   at Vuforia.DelegateHelper.InvokeDelegate (System.Delegate action, System.Object[] args) [0x0000f] in <c6d6035d26434a6a94f7179ae382aebf>:0 UnityEngine.Debug:LogError(Object) Vuforia.DelegateHelper:InvokeDelegate(Delegate, Object[]) Vuforia.DelegateHelper:InvokeWithExceptionHandling(Action) Vuforia.VuforiaARController:StartAfterInitializationCompleted() Vuforia.VuforiaARController:Start() System.Delegate:DynamicInvoke(Object[]) Vuforia.DelegateHelper:InvokeDelegate(Delegate, Object[]) Vuforia.DelegateHelper:InvokeWithExceptionHandling(Action) Vuforia.VuforiaBehaviour:Start()

 

And here are my code to enable the Instant Image Target:- Scene scene = SceneManager.GetActiveScene();                 Debug.Log(PlayerPrefs.GetString("SceneLoading"));         if (scene.name == "ARScene")         {             LoadScene_Name = PlayerPrefs.GetString("SceneLoading");

            if (PlayerPrefs.GetString("SceneLoading") != "AllScene")             {                                  GameObject go = FindInActiveObjectByName(LoadScene_Name);                 go.SetActive(true);                 go.GetComponent<SetupImageTarget>().enabled = true;

            }             else             {                 AllControllers = FindInActiveObjectsByTag("Controller");

                foreach (GameObject go in AllControllers)                 {                     go.SetActive(true);                     go.GetComponent<SetupImageTarget>().enabled = true;                 }             }

        }     }  

Hi,

Every time you exit an AR scene and enter a NON-AR scene, Vuforia is stopped automatically. In this case, your created Image Target at Run-time, will be destroyed on scene-exit and recreated on re-entry.