Log in or register to post comments

All augmentations visible on first image target detection

May 30, 2018 - 2:44am #1

Hello,

I'm currently working on an application for android using the Vuforia Unity API.

In my use case I am dynamically loading a DataSet and instantiating GameObjects, just like described in this article:

https://developer.vuforia.com/forum/faq/unity-load-dataset-setup-trackables-runtime

However, I'm Instantiating a different augmentation for each TrackableBehaviour. 

 

Here's my problem:

When I hold my camera over the first ImageTarget, I see all augmentations I have instantiated. 

When I hold my camera over the second ImageTarget, I see all augmentations, except for the first one.

When I hold my camera over the third ImageTarget, I see all augmentations, except for the first one and the second one.

...

After I have scanned all of the ImageTargets, everything works fine, i.e. I only see the augmentations that I have instantiated for the ImageTarget, when it's tracked.

So it seems as if all augmentations are visible at the beginning until their corresponding ImageTargets have been scanned. Then they are somehow set to invisible and only show when their corresponding ImageTarget is scanned.

Unfortunately I could not yet find a way to solve this problem and I hope someone can tell me what is going on here.

 

Thanks in advance,

Alex

All augmentations visible on first image target detection

June 5, 2018 - 2:54am #2

I fixed it myself.

I had to register a new TrackableEventHandler for every augmentation:

tb.RegisterTrackableEventHandler(new MyDefaultEventHandler(augmentation));

Here's the code of my TrackableEventHandler 

public class MyDefaultEventHandler : ITrackableEventHandler

{

    private GameObject obj;

    public MyDefaultEventHandler(GameObject obj)

    {

        this.obj = obj;

    }

    public void OnTrackableStateChanged(

                                         TrackableBehaviour.Status previousStatus,

                                         TrackableBehaviour.Status newStatus)

    {

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

            newStatus == TrackableBehaviour.Status.TRACKED ||

            newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED)

        {

            obj.SetActive(true);

           

        }

        else

        {

            obj.SetActive(false);

        }

    }

}

 

Log in or register to post comments