I have a GameObject that has a script called AristaImageTarget which implements the ITrackableEventHandler interface and contains a reference to an ImageTargetBehaviour which is a child of it. The problem is that every time I delete AristaImageTarget I get this error
MissingReferenceException: The object of type 'ImageTargetBehaviour' has been destroyed but you are still trying to access it.
and the culprid seems to be the ARCamera according the console when I click on the error. So I decided to do this on OnDestroy on AristaImageTarget
trackable.UnregisterTrackableEventHandler (this);
Destroy (trackable);
Where trackable is the reference to the ImageTargetBehaviour. But I still get the error ![]()
Update
This new OnDestroy seems to work better; now no errors are shown.
trackable.UnregisterTrackableEventHandler (this);
TrackerManager.Instance.GetStateManager().DestroyTrackableBehavioursForTrackable (trackable.Trackable, true);
However, when I instantiate a new AristaImageTarget and programatically load the same dataset, it doesn’t seem to recognize the target.