Start a new topic

How to get a reference to instantiated prefab (drawable)?

I'm trying to take manual control of my augmentation (fading meshes, media in/out) when image targets are recognised and lost. This all works fine in different use cases except when the augmentation is instantiated from prefab and the target is lost. The problem arises from the fact that Wikitude places the instantiated prefab as a child to the ImageTracker and that is destroyed by Wikitude immediately after the target is lost. 

To restore the functionality I'm after I would need to somehow 


a) parent the instantiated prefab one level up so it would be child of ImageTrackable


_or_


b) somehow defer the destruction of ImageTarget until I'm done with manipulating my prefab and then destroy both


Is either of these feasible?


Hi,


If you are not using multiple image tracking, you can simply set your augmentations as child GameObjects of the ImageTrackable and toggle their visibility using the OnImageRecognized / OnImageLost events from the ImageTrackable.


If you are using multiple image tracking, you can get a reference to the drawable through the ImageTarget that gets passed to you when the OnImageRecognized / OnImageLost events are called. So, for example, if you want to fade out the augmentation, you would register to the OnImageLost event, and in the callback de-parent your instantiated prefab from the drawable, trigger the fade out, and manually destroy the augmentation when the animation is done. The destruction of the drawable will still continue after the OnImageLost event is called, but that won't affect the augmentation anymore.


Please let us know if we can provide additional assistance.


Best regards,

Alexandru



Thanks. I had missed that ImageTarget has Drawable property that holds the reference to the object (kinda obvious though now that I think of it :) Anyway, works perfectly now.


Cheers,

jokke

Login or Signup to post a comment