Log in or register to post comments

Issue when reloading scene Vuforia 6.5.22

December 12, 2017 - 7:09am #1

EDIT: Vuforia version 6.5.22

Hello !

I am working on a HoloLens application (Unity 2017.2.0f3 with Vuforia 6.5.22). Everything works fine but when I want to reload my scene the screen freezes. In play mode my console shows the following error multiple times:

Quote:

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.



 

I can see that nothing has been deleted. I don't know where this error comes from, am i missing something ? Any suggestions?

 

Edit: This problem occurs when I select "Optical See-Through" for Eyewear Type and "Hololens" for See Through Config.

Thanks !

Issue when reloading scene Vuforia 6.5.22

January 31, 2018 - 12:26am #6

If anyone needs a solution where you don't want to keep the camera for every scene (e.g. because you wired it in the editor):

DigitalEyewearARController.Instance.SetViewerActive(true, true);

This re-initializes the camera-connection manually and fixes the issue -- at least for our project.

You might also want to re-initialize the tracker, but at the moment, Vuforia seems to do this right by itself. Code would be:

TrackerManager.Instance.GetStateManager().ReassociateTrackables();

Issue when reloading scene Vuforia 6.5.22

December 14, 2017 - 7:02am #5

I fixed it.

You have to delete ARCamera from every next scene.

This object need to be only in first scene.

 

You have to add this script to ARCamera:  

using UnityEngine;
using System.Collections.Generic;
using Vuforia;

public class DontDestroy : MonoBehaviour
{

    // Use this for initialization
    void Start()
    {
DontDestroyOnLoad (this.gameObject);


        }
    }

 

This works for scenes includes AR elements.

 

When you want to change scene to non AR scene, you have to add script VuforiaBehavior (from Component->scripts->vuforia) to MainCamera in new scene (non AR) and disable it in Inspector. Thanks to this, Vuforia will not runing.

Issue when reloading scene Vuforia 6.5.22

December 14, 2017 - 2:07am #4

Hello,



I'm reloading it in the calssic way:

SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);

 

Issue when reloading scene Vuforia 6.5.22

December 13, 2017 - 11:53pm #3

Hello,

 

I've got the same problem

My project contains 4 almost the same scenes.

Each of them has:

 

1 - ARCamera

2 - ImageTarget

3-  ImageTarget with VirtualButton to change scenes

 

The only one difference is to show different objects with the same ImageTarget.

 

Script to changes scenes:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Vuforia;
using UnityEngine.SceneManagement;


public class vbButton : MonoBehaviour, IVirtualButtonEventHandler {

    public GameObject vbBtnObj;

// Use this for initialization
void Start () {
        vbBtnObj = GameObject.Find("Przycisk");
        vbBtnObj.GetComponent<VirtualButtonBehaviour>().RegisterEventHandler(this);
        DontDestroyOnLoad(transform.gameObject);
      
}

    public void OnButtonPressed(VirtualButtonBehaviour vb)
    {
     SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
     Debug.Log("Button pressed");
    }
   
    public void OnButtonReleased(VirtualButtonBehaviour vb)
    {
     Debug.Log("Button released");
    }
   
}

 

After switching to optical see through and clicking button, there is camera crash with error:

Quote:

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.

 

For previous version this solution works pretty well: https://developer.vuforia.com/forum/faq/unity-scene-swap-and-dataset-persistence

Now its not working at all.

 

We have to finish project asap.. and such a stupid problem occured. Any ideas?

Issue when reloading scene Vuforia 6.5.22

December 13, 2017 - 4:29pm #2

Hello devlodc,

How are you reloading your scene?

Thanks,

Vuforia Support

Log in or register to post comments