首页 > 代码库 > Vuforia判断当识别追踪的对象

Vuforia判断当识别追踪的对象

  

 方法一,如果有多个识别对象,在Update中循环识别对象数组,获取TrackableBehaviour组件

foreach (var item in trackObjects)        {            var mTrackableBehaviour = item.GetComponent<Vuforia.TrackableBehaviour>();            if (mTrackableBehaviour != null && (int)mTrackableBehaviour.CurrentStatus>1)            {                if (mTrackableBehaviour.transform.name == "追踪物体的Name")                    {  }                Debug.Log("追踪的物体名字为:"+mTrackableBehaviour.Trackable.Name);                break;            }            else            {                //            }        }

方法二,直接把代码挂在识别对象上,判断该对象是否被识别

       var mTrackableBehaviour = GetComponent<Vuforia.TrackableBehaviour>();            if (mTrackableBehaviour != null && (int)mTrackableBehaviour.CurrentStatus>1)            {                if (mTrackableBehaviour.transform.name == "追踪物体的Name")                    {  }                Debug.Log("追踪的物体名字为:"+mTrackableBehaviour.Trackable.Name);                break;            }

识别对象状态枚举:

public enum Status        {            NOT_FOUND = -1,            UNKNOWN = 0,            UNDEFINED = 1,            DETECTED = 2,            TRACKED = 3,            EXTENDED_TRACKED = 4,        }

 相关代码 38楼:http://forum.unity3d.com/threads/help-with-vuforia-project.215147/

Vuforia判断当识别追踪的对象