Log in or register to post comments

enable and disable Image Targets

October 11, 2019 - 10:24am #1

How does one, using Unity, enable and disable sets of Vuforia Image Markers?

I've tried everything I can think of and others with even more Unity scripting background have tried for me as well.  what I want is very simple to state, 

 

I want to have a set of Vuforia Image Markers to be active and a different set to be inactive, then I want to turn off/disable the first set and turn on/enable the 2nd set.

Frankly I thought using SetActive in Unity should just do it but nope, the ones that are off are never coming back on again when I set them to active.

All I want to do is have one set of Image Markers turned on (3 of them) and one set turned off (3 target markers).  When something happens, I want to turn off the original set of Markers and turn on the 2nd set of Markers. 

We tried TrackerManager .Instance.GetStateManager().ReassociateTrackables() seems to do nothing.

We tried the camera deinit and reinit, it didn't help.

We tried updated states, and reassociating trackables as above, don't work.

 

Super super basic ask it seems to me and my pals, we just want to turn some Image Targets on and some off, then turn some on that are off and some off that are on, but somehow lots of threads ask about it and not one figures it out to work.

 

Is there a way to do this? or do I need to go all leave them on and run nonexistent animators that are nothing for those I want to pretend are not on in my game till I want the real animations to run?

 

Thanks for anything.

I've tried to read all the threads asking about related stuff on this.  I'm maybe needing to jump to Wikitude to get this from AR Markers?

 

enable and disable Image Targets

October 11, 2019 - 10:53am #2

Maybe try seperating them into different data sets and then use something like below.  Make sure Vuforia is completely loaded first.  If you just need to turn off visually and not the actual tracking you can subclass DefaultTrackableEventHandler and overrive tracking found and tracking lost.

 

loadSet("Vuforia/MyDataSet.xml"); 

public void loadSet(string dataSetString)
{
  ObjectTracker objectTracker = (ObjectTracker)TrackerManager.Instance.GetTracker<ObjectTracker>();
 
  if (objectTracker!=null)
  {
   objectTracker.Stop();
   IEnumerable<DataSet> activeDataSets = objectTracker.GetActiveDataSets();
  
   while (activeDataSets.Count()>0)
   {
    DataSet anActiveDataSet = activeDataSets.ElementAt(0);
    objectTracker.DeactivateDataSet(anActiveDataSet);
   }
  
   if (dataSetString!="")
   {
    IEnumerable<DataSet> dataSets = objectTracker.GetDataSets();
    int i = 0;
    for (i = 0;i<dataSets.Count();i++)
    {
     if (dataSets.ElementAt(i).Path == dataSetString)
     {
      break;
     }
    }
    Debug.Log ("<color=red>"+dataSets.ElementAt(i).Path+"</color>");
    objectTracker.ActivateDataSet(dataSets.ElementAt(i));
   }
   else
   {
    Debug.Log ("No Active Sets!");
   }
   objectTracker.Start();
  }
}
Log in or register to post comments