Log in or register to post comments

[Unity] Dynamically loaded/unloaded dataset only works once

July 20, 2020 - 8:01am #1

Hi,

My Unity app downloads AreaTarget dataset and loads them on demand. (I do not rely on an existing AreaTarget object in the scene)

My issue: after the 1st AreaTarget dataset is loaded and then unloaded, the next (other) AreaTarget dataset will load correctly but won't work (no tracking). I checked than all dataset work, so it has probably to do with initializing/loading/unloading code...

The procedure :

1- 1st AreaTarget dataset:

TrackerManager.Instance.InitTracker<PositionalDeviceTracker>();

TrackerManager.Instance.InitTracker<AreaTracker>();

VuforiaBehaviour.Instance.enabled = true;

var tracker = TrackerManager.Instance.GetTracker<AreaTracker>();

tracker.Stop();

var dataSet = tracker.CreateDataSet();

dataSet.Load(...);

tracker.ActivateDataSet(dataSet);

tracker.Start();

[...] // track target... IT WORKS

tracker.Stop();

tracker.DeactivateDataSet(dataSet);

TrackerManager.Instance.GetStateManager().DestroyTrackableBehavioursForTrackable(behavior.Trackable);

tracker.DestroyDataSet(dataSet);

tracker.Start();

VuforiaBehaviour.Instance.enabled = false;

 

2- next AreaTarget dataset is similar except initialization:

VuforiaBehaviour.Instance.enabled = true;

var tracker = TrackerManager.Instance.GetTracker<AreaTracker>();

tracker.Stop();

var dataSet = tracker.CreateDataSet();

dataSet.Load(...);

tracker.ActivateDataSet(dataSet);

tracker.Start();

[...] // track target... IT DOES NOT WORK!

tracker.Stop();

tracker.DeactivateDataSet(dataSet);

TrackerManager.Instance.GetStateManager().DestroyTrackableBehavioursForTrackable(behavior.Trackable);

tracker.DestroyDataSet(dataSet);

tracker.Start();

VuforiaBehaviour.Instance.enabled = false;

[Unity] Dynamically loaded/unloaded dataset only works once

August 12, 2020 - 12:30am #2

Should anyone stumble upon this:

The issue comes from PositionalDeviceTracker being totally lost after Vuforia stops and restarts.

The fix is to call

TrackerManager.Instance.GetTracker<PositionalDeviceTracker>().Reset()

after

VuforiaBehaviour.Instance.enabled = true

 

Thanks Marius/Vuforia for the support!

Log in or register to post comments