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

匆匆过客 提交于 2019-12-20 04:12:44

问题


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 after tracking lost?


回答1:


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");
}


来源:https://stackoverflow.com/questions/36686984/how-to-keep-tracked-image-target-model-object-after-tracking-lost

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!