代码语言:javascript复制
void CreateImageTarget()
{
IEnumerable<TrackableBehaviour> tbs = TrackerManager.Instance.GetStateManager().GetTrackableBehaviours();
foreach (TrackableBehaviour tb in tbs)
{
Debug.Log(tb.TrackableName);
tb.gameObject.name = "ImageTarget";
//下面这两句不能少,需要给它加上这两个组件
tb.gameObject.AddComponent<DefaultTrackableEventHandler>();
tb.gameObject.AddComponent<TurnOffBehaviour>();
}
}