Start a new topic
Solved

Can Tracker change WTO in Script?

Hello,


In the script, I would like to change the Tracker's Target Collection to another WTO file.


image


I tried changing TargetPath in Tracker.TargetCollectionResource, but only what was seen in the Inspector was changed, and the target perceived by the actual tracker remained unchanged.

 

        if(isCameraWayLeft)
        {
            Tracker.TargetCollectionResource.TargetPath = "sorento_left.wto";
        }
        else
        {
            Tracker.TargetCollectionResource.TargetPath = "sorento_right.wto";
        }

 

How do I change the WTO file when I want to script it and recognize the target of the WTO file?




Hi,


Could you please provide further details as requested once you created the post:


  • Which version of the SDK are you using?
  • Are you working with the Professional or the Expert Edition of our Unity Plugin?
  • What Unity version are you using?

Thx and greetings

Nicola


Wikitude SDK : Professional Edition v9.2

Unity : 2019.4.4f


Thank you.

Hi,


I merged those 2 threads as they are dealing with the same topic and having multiple topics for the same issue is very hard to follow.


As for the answer time, the question is already assigned to our core team and they will get back to you once they are on the support tasks. Please note that response times may vary.


Thx and greetings

Nicola

Hello,

After changing the target path during runtime, the tracker has to be re-initialized to load the new target collection.
That can be done like this:

public void ChangeTargetCollection() {        
  if (isCameraWayLeft) {
    _Tracker.TargetCollectionResource.TargetPath = "sorento_left.wto";
    _Trackable.TargetPattern = "*";
  } else {
    _Tracker.TargetCollectionResource.TargetPath = "sorento_right.wto";
    _Trackable.TargetPattern = "*";
  }
  GameObject oldTracker = _Tracker.gameObject;        
  GameObject newTracker = Instantiate(oldTracker, Vector3.zero, Quaternion.identity, oldTracker.transform.parent.transform);
  DestroyImmediate(oldTracker);
  _Tracker = newTracker.GetComponent<ObjectTracker>();
  _Trackable = newTracker.GetComponentInChildren<ObjectTrackable>();
}


Kind regards,
Gökhan




Login or Signup to post a comment