Hi
I'm willing to use Vuforia in Unity to realise a function----when track found the image target it renders some objects, but when it lost the image target it renders other objects.
I read DefaultTrackableEventHandler in the vuforia
protected virtual void OnTrackingFound() { var rendererComponents = GetComponentsInChildren<Renderer>(true); var colliderComponents = GetComponentsInChildren<Collider>(true); var canvasComponents = GetComponentsInChildren<Canvas>(true);
// Enable rendering: foreach (var component in rendererComponents) component.enabled = true;
// Enable colliders: foreach (var component in colliderComponents) component.enabled = true;
// Enable canvas': foreach (var component in canvasComponents) component.enabled = true;
}
protected virtual void OnTrackingLost() { var rendererComponents = GetComponentsInChildren<Renderer>(true); var colliderComponents = GetComponentsInChildren<Collider>(true); var canvasComponents = GetComponentsInChildren<Canvas>(true);
// Disable rendering: foreach (var component in rendererComponents) component.enabled = false;
// Disable colliders: foreach (var component in colliderComponents) component.enabled = false;
// Disable canvas': foreach (var component in canvasComponents)
component.enabled = false;
}
But it will appear all the children under the ImageTarget.
How can I rewrite this method? And how can I use C# get the object I put under the ImageTarget in Unity
Thanks a lot! And wish you a happy day!
----Summy
Hi,
Hi,
OnTrackingFound will activate the Dataset in Unity, OnTrackingLost() will disable it.
I am not quite sure about your use-case, what do you want to achieve with this methods?
Thank you.
Vuforia Engine Support
Personally I inherited
Personally I inherited "DefaultTrackableEventHandler.cs" as sub class of it (make a new script for this)
and overidded OnTrackingLost(), OnTrackingFound().