I have seen that you can fetch a Target Collection on runtime in unity and create an Image Tracker.
Am i able to loop through the Image Targets (img1, img2, img3, ...) of the wtc file and attach different drawables to them?
So as a real world example:
I have a target collection with 5 images, i want those images to have different videos for each one. I will have a standard Video Prefab but the url for the video will change according to what image is being tracked.
Thank you in advance.
There are two ways to accomplish this.
1. You can have a single ImageTrackable that is configured to recognize all the Image Targets in the collection. In this Image Trackable you add a callback method to the OnImageRecognized and OnImageLost events. When an Image Target is recognized your callback will be called with an ImageTarget, from which you can get the name of the image that was recognized. Based on the name, you can instantiate the appropriate prefab and place it as a child GameObject of the Trackable. When the Image Target is lost, the OnImageLost event will be triggered and here you should destroy the prefab created earlier.
2. You can have an ImageTrackable for each of the Image Targets. Each ImageTrackable is configured to recognize a single image from the collection. Additionally, you set a unique prefab in the Drawable field of the ImageTrackable. At runtime, when the image associated with this ImageTrackable is recognized, the prefab configured as a Drawable will be instantiated and set as a child GameObject to the ImageTrackable. When the image is lost, the instantiated prefab is automatically destroyed.
I would recommend the first method, since it is more flexible and scalable.
It is possible to swap the Drawable, but the change will only happen the next time you recognize the associated target. That is because the prefab is instantiated when the target is recognized, so even if you change the prefab, the instantiated version will still be visible until the target is lost.
forgot to mention that this has to be done dynamically at run-time