How to keep tracked Image Target model object after tracking lost?

前端 未结 1 1617
不思量自难忘°
不思量自难忘° 2021-01-27 03:22

I am developing AR application with Unity3d and Vuforia. I want to keep ImageTarget object that tracked found when It was lost. How to keep tracked Image Target model object aft

相关标签:
1条回答
  • 2021-01-27 04:04

    The script that handles what happens when tracking is lost is called DefaultTrackableEventHandler.cs and is found in Assets > Vuforia > Scripts. In that file you will find a function OnTrackingLost() This function disables all the renderComponents and colliderComponents for each of the children of the ImageTarget. If you want your object to stay visible comment out the following foreach loops like so:

    private void OnTrackingLost()
    {
        Renderer[] rendererComponents = GetComponentsInChildren<Renderer>(true);
        Collider[] colliderComponents = GetComponentsInChildren<Collider>(true);
    
        /*
        // Disable rendering:
        foreach (Renderer component in rendererComponents)
        {
            component.enabled = false;
        }
    
        // Disable colliders:
        foreach (Collider component in colliderComponents)
        {
            component.enabled = false;
        }
        */
    
        Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " lost");
    }
    
    0 讨论(0)
提交回复
热议问题