0
votes

I know the below code disappears canvas on tracking lost in Vuforia. Under DefaultTrackableEvent.cs,

Canvas[] canvasComponents = GetComponentsInChildren<Canvas>(true);

        // Disable canvas:
        foreach (Canvas component in canvasComponents)
        {
            component.enabled = false;
        }

Now i have 3 canvas and i want 2 canvas elements to disappear on target lost. The above is not working for this! Can you help me with a solution!

2

2 Answers

0
votes

If you know which one of these you want to keep enabled, you can skip it by using if statement.

Canvas[] canvasComponents = GetComponentsInChildren<Canvas>(true);

// Disable canvas:
foreach (Canvas component in canvasComponents)
{
    if(component.gameObject.tag != "someTag")
        component.enabled = false;
}

now set tag of that specific canvas to someTag

Hope this helps

0
votes

I make it work by keeping both the canvas inside the parent GameObject and placing the parent GameObject inside ImageTarget in Hierarchy.

BTW, always make sure that the canvas to be hidden on TargetLost must be always inside ImageTarget in Hierarchy !