Log in or register to post comments

Can't enable VuforiaBehaviour after disabling and changing scenes

April 20, 2018 - 11:14am #1

My setup:

1. Using Unity 2018.10b13

2. In the Loading Scene, Vuforia is disabled by default. The user can choose to manually turn Vuforia on to anchor an object on an image. Basically, that function calls VuforiaBehaviour.Instance.enabled = true.

3. Once the anchor image has been found, Vuforia is disabled (VuforiaBehaviour.Instance.enabled = false) and the the Main Scene loads.

4. From the Main Scene, you can restart and come back to the Loading Screen, where you should be able to rescan to anchor your object again.

5. However, when VuforiaBehaviour.Instance.enabled = true is called again, I get this error:

Exception in callback: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> UnityEngine.MissingReferenceException: The object of type 'Camera' 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.Camera:ResetStereoProjectionMatrices ()

  at Vuforia.DedicatedEyewearCameraConfiguration.ResetStereoProjectionMatrices () [0x00000] in <filename unknown>:0

  at Vuforia.DedicatedEyewearCameraConfiguration.Destroy () [0x00000] in <filename unknown>:0

  at Vuforia.DigitalEyewearARController.set_CameraConfiguration (ICameraConfiguration value) [0x00000] in <filename unknown>:0

  at Vuforia.DigitalEyewearARController.ConfigureView () [0x00000] in <filename unknown>:0

  at Vuforia.DigitalEyewearARController.OnVuforiaStarted () [0x00000] in <filename unknown>:0

  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception&)

  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x000d0] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222

  --- End of inner exception stack trace ---

  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x000eb] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232

  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115

  at System.Delegate.DynamicInvokeImpl (System.Object[] args) [0x000b9] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Delegate.cs:443

  at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args) [0x00018] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/MulticastDelegate.cs:71

  at System.Delegate.DynamicInvoke (System.Object[] args) [0x00000] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Delegate.cs:415

  at Vuforia.DelegateHelper.InvokeDelegate (System.Delegate action, System.Object[] args) [0x00000] in <filename unknown>:0

UnityEngine.Debug:LogError(Object)

Vuforia.DelegateHelper:InvokeDelegate(Delegate, Object[])

Vuforia.DelegateHelper:InvokeWithExceptionHandling(Action)

Vuforia.VuforiaARController:Start()

System.Delegate:DynamicInvoke(Object[])

Vuforia.DelegateHelper:InvokeDelegate(Delegate, Object[])

Vuforia.DelegateHelper:InvokeWithExceptionHandling(Action)

I also get this error if I simply try to enable Vuforia in a different scene after I have disabled it in the first scene.

Is there a better way to reset Vuforia at runtime besides VuforiaBehaviour.Instance.enabled = true/false? Any ideas would be greatly appreciated!

Have tried downgrading to Unity 2017.4.1.1f1 and upgrading to Unity 2018.2.0b1, no dice there.

Log in or register to post comments