Log in or register to post comments

Vuforia can not create dataset. Black screen

August 24, 2016 - 9:34am #3

I've found a few topics on this but nothing that can solve my issue.

I have 5 ImageTargets in a scene that all link to separate scenes which, also link back to the first scene.

When I've been back and forth a few times, I get a bunch of error messages and the ARCamera shows a black screen (it still shows the GUI).

This is in the Editor but it also happens when pushed to iOS.

The errors I get:

MissingReferenceException: The object of type 'GameObject' 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.

UnityEngine.GameObject.GetComponentsInChildren[Canvas] (Boolean includeInactive) (at /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineGameObjectBindings.gen.cs:142)

Vuforia.AimDefaultTrackableEventHandler.OnTrackingLost () (at Assets/Vuforia/Scripts/AimDefaultTrackableEventHandler.cs:124)

Vuforia.AimDefaultTrackableEventHandler.OnTrackableStateChanged (Status previousStatus, Status newStatus) (at Assets/Vuforia/Scripts/AimDefaultTrackableEventHandler.cs:74)

Vuforia.TrackableBehaviour.OnTrackerUpdate (Status newStatus)

Vuforia.DataSetTrackableBehaviour.OnTrackerUpdate (Status newStatus)

Vuforia.StateManagerImpl.SetTrackableBehavioursForTrackableToNotFound (Trackable trackable)

Vuforia.ObjectTrackerImpl.Stop ()

Vuforia.VuforiaAbstractBehaviour.StopVuforia ()

Vuforia.VuforiaAbstractBehaviour.OnDisable ()

Could not deinitialize the tracker.

UnityEngine.Debug:LogError(Object)

Vuforia.TrackerManagerImpl:DeinitTracker()

Vuforia.VuforiaAbstractBehaviour:OnDestroy()

Could not create dataset.

UnityEngine.Debug:LogError(Object)

Vuforia.ObjectTrackerImpl:CreateDataSet()

Vuforia.DatabaseLoadAbstractBehaviour:LoadDatasets()

Vuforia.VuforiaAbstractBehaviour:Start()

Failed to set frame format

UnityEngine.Debug:LogError(Object)

Vuforia.CameraDeviceImpl:SetFrameFormat(PIXEL_FORMAT, Boolean)

Vuforia.CameraDeviceImpl:ForceFrameFormat(PIXEL_FORMAT, Boolean)

Vuforia.CameraDeviceImpl:Stop()

Vuforia.VuforiaAbstractBehaviour:StopVuforia()

Vuforia.VuforiaAbstractBehaviour:OnDisable()

I have edited the DefaultTrackableEventHandler to make it augment GUI elements when tracking is lost, then augment different content when tracking is found. This is the source of the "The object of type 'GameObject' has been destroyed but you are still trying to access it." error

Here's my edited script:

 

using UnityEngine;

using System.Collections;

using UnityEngine.UI;



namespace Vuforia

{

    /// <summary>

    /// A custom handler that implements the ITrackableEventHandler interface.

    /// </summary>

    public class AimDefaultTrackableEventHandler : MonoBehaviour,

                                                ITrackableEventHandler

    {

        #region PRIVATE_MEMBER_VARIABLES

        private TrackableBehaviour mTrackableBehaviour;

  

        #endregion // PRIVATE_MEMBER_VARIABLES

        #region UNTIY_MONOBEHAVIOUR_METHODS

  public GameObject PlayButton;

  public GameObject FindTracker;

  public GameObject FT;

  public GameObject Outline;

  void Start()

        {

 

   Canvas[] canvasComponents = PlayButton.GetComponentsInChildren<Canvas>(true);

   Canvas[] otherCanvasComponents = FindTracker.GetComponentsInChildren<Canvas>(true);

   foreach (Canvas component in canvasComponents) {

    component.enabled = false;

   }

   foreach (Canvas component in otherCanvasComponents) {

    component.enabled = true;

   }

            mTrackableBehaviour = GetComponent<TrackableBehaviour>();

            if (mTrackableBehaviour)

            {

                mTrackableBehaviour.RegisterTrackableEventHandler(this);

            }

        }

        #endregion // UNTIY_MONOBEHAVIOUR_METHODS

        #region PUBLIC_METHODS

        /// <summary>

        /// Implementation of the ITrackableEventHandler function called when the

        /// tracking state changes.

        /// </summary>

        public void OnTrackableStateChanged(

                                        TrackableBehaviour.Status previousStatus,

                                        TrackableBehaviour.Status newStatus)

        {

            if (newStatus == TrackableBehaviour.Status.DETECTED ||

                newStatus == TrackableBehaviour.Status.TRACKED ||

                newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED)

            {

                OnTrackingFound();

            }

            else

            {

                OnTrackingLost();

            }

        }

        #endregion // PUBLIC_METHODS

        #region PRIVATE_METHODS



        private void OnTrackingFound()

  {

   FT.GetComponent<Animation> ().Play ("FTAnim");

   StartCoroutine ("TrackerAnim");

   Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found");

  }

  IEnumerator TrackerAnim(){

   yield return new WaitForSeconds (1);

   Outline.GetComponent<Animation> ().Play ();

   Canvas[] otherCanvasComponents = FindTracker.GetComponentsInChildren<Canvas> (true);

   Canvas[] canvasComponents = PlayButton.GetComponentsInChildren<Canvas> (true);    

   Renderer[] rendererComponents = GetComponentsInChildren<Renderer> (true);

   Collider[] colliderComponents = GetComponentsInChildren<Collider> (true);

   // Enable rendering:

   foreach (Renderer component in rendererComponents) {

    component.enabled = true;

   }

   foreach (Collider component in colliderComponents)

   {

    component.enabled = true;

   }

   foreach (Canvas component in canvasComponents) {

    component.enabled = true;

   }

   foreach (Canvas component in otherCanvasComponents) {

    component.enabled = false;

   }

         

        }

 

        private void OnTrackingLost()

        {

 

   Canvas[] canvasComponents = PlayButton.GetComponentsInChildren<Canvas>(true);

   Canvas[] otherCanvasComponents = FindTracker.GetComponentsInChildren<Canvas>(true);

            Renderer[] rendererComponents = GetComponentsInChildren<Renderer>(true);

            Collider[] colliderComponents = GetComponentsInChildren<Collider>(true);

            // Disable rendering:

            foreach (Renderer component in rendererComponents)

            {

  

                component.enabled = false;

            }

            // Disable colliders:

            foreach (Collider component in colliderComponents)

            {

                component.enabled = false;

            }

   foreach (Canvas component in canvasComponents) {

    component.enabled = false;

   }

   foreach (Canvas component in otherCanvasComponents) {

    component.enabled = true;

   }

            Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " lost");

        }

        #endregion // PRIVATE_METHODS

  

}

}

Does anyone know whats causing this? I'm in the middle of a huge project and this is a real struggle

Vuforia can not create dataset. Black screen

August 24, 2016 - 11:44am #2

Hello,

Did you also check the box for "Keep Trackable Prefabs Alive"? It is just below the checkbox for "Keep AR Camera Alive".

https://developer.vuforia.com/forum/vuforia-40/vuforia-40-keep-camera-alive-disables-markers

Thanks

Vuforia can not create dataset. Black screen

August 25, 2016 - 5:46am #1

Hi, 

Thanks for replying. I've ticked "Keep ARCamera Alive" (but not "Keep Trackable Prefabs Alive" as I'm augmenting something different in each scene) and done some basic testing and so far I haven't come across the problem. 

So a cautious thank you to you!

As reference to anyone else with this issue: Set the ARCamera in one scene, ticking "Keep ARCamera Alive", then delete all the other ARCameras in other scenes

Log in or register to post comments