//Set the target manager behavior protected void Awake() { m_TrackedImageManager = GameObject.FindObjectOfType <ARTrackedImageManager>(); if (m_TrackedImageManager == null) { SimplifyXRDebug.SimplifyXRLog(SimplifyXRDebug.Type.AuthorError, "[TARGET] No ARTrackedImageManager in the scene. This component is required to use the ARFoundationAdapter"); } SimplifyXRTargetManager.Instance.SetBehavior(new ARFoundationImageTargetManagerBehaviour()); TrackingManager.Instance.SetTrackingManagerBehavior(new BaseTrackingCameraBehavior()); }
//Initial behavior set public void Start() { SimplifyXRTargetManager.Instance.TrackPreloadedObject(this); SimplifyXRDebug.SimplifyXRLog(SimplifyXRDebug.Type.AuthorDebug, "[TARGET] New target {0} being tracked", SimplifyXRDebug.Args(GetTargetName())); //Determine if the user would like to start tracking immediately or not if (StartTrackingImmediately) { StartTracking(); } CallPoseLost(); }
//Used to start tracking a dataset protected override void ActuallyShowObject(SimplifyXRTargetAdapter toShow) { try { if (!myActiveObject.GetAllObjects().Contains(toShow)) { myActiveObject.TrackObject(toShow); } ARFoundationAdapter adapter = toShow as ARFoundationAdapter; //TODO Start the tracking adapter.StartTracking(); SimplifyXRDebug.SimplifyXRLog(SimplifyXRDebug.Type.DeveloperDebug, "Tracking the passed SimplifyXRTarget {0}.", SimplifyXRDebug.Args(toShow.GetTargetName())); } catch { SimplifyXRDebug.SimplifyXRLog(SimplifyXRDebug.Type.DeveloperDebug, "The passed SimplifyXRTarget {0} is not a vuforia target. Please change target manager behaviors before attempting to load this target", SimplifyXRDebug.Args(toShow.GetTargetName())); } }
//Used to stop tracking a dataset protected override void ActuallyHideObject(SimplifyXRTargetAdapter toHide) { try { //see of the object has already been loaded if (myActiveObject.GetAllObjects().Contains(toHide)) { ARFoundationAdapter adapter = toHide as ARFoundationAdapter; //TODO stop the tracker adapter.StopTracking(); SimplifyXRDebug.SimplifyXRLog(SimplifyXRDebug.Type.DeveloperDebug, "Stoping Tracking the passed SimplifyXRTarget {0}.", SimplifyXRDebug.Args(toHide.GetTargetName())); } else { SimplifyXRDebug.SimplifyXRLog(SimplifyXRDebug.Type.DeveloperDebug, "The passed SimplifyXRTarget {0} is being tracked by this manager. Please track the target before calling this method.", SimplifyXRDebug.Args(toHide.GetTargetName())); } } catch { SimplifyXRDebug.SimplifyXRLog(SimplifyXRDebug.Type.DeveloperDebug, "The passed SimplifyXRTarget {0} is not a VisionLib target. Please change target manager behaviors before attempting to unload this target", SimplifyXRDebug.Args(toHide.GetTargetName())); } }
//Stop tracking this object protected void OnDestroy() { SimplifyXRDebug.SimplifyXRLog(SimplifyXRDebug.Type.AuthorDebug, "[TARGET] Target {0} destroyed", SimplifyXRDebug.Args(GetTargetName())); SimplifyXRTargetManager.Instance.RemoveObject(GetTargetName()); }
//Not implemented. No concept of active protected override void ActuallySetActive(SimplifyXRTargetAdapter toSetActive) { SimplifyXRDebug.SimplifyXRLog(SimplifyXRDebug.Type.Error, "Cannot set SimplifyXRTarget {0} as the active target using the current behavior {1}. This behavior does not track active targets.", SimplifyXRDebug.Args(toSetActive.GetTargetName(), this)); }
//Method not implemented. Image targets can only be added in a scene ahead of runtime protected override void ActuallyAddObject(string toAdd) { SimplifyXRDebug.SimplifyXRLog(SimplifyXRDebug.Type.Error, "Cannot Add an SimplifyXRTarget named {0}. This behavior does not add targets at runtime. Create targets in the scene before runtime.", SimplifyXRDebug.Args(toAdd)); }
//Initial behavior set public void Start() { SimplifyXRTargetManager.Instance.TrackPreloadedObject(this); SimplifyXRDebug.SimplifyXRLog(SimplifyXRDebug.Type.AuthorDebug, "[TARGET] New target {0} being tracked", SimplifyXRDebug.Args(GetTargetName())); CallPoseLost(); }