"We offer new support options and therefor the forums are now in read-only mode! Please check out our Support Center for more information." - Vuforia Engine Team

Unity - How do I get the list of active Trackables

This articles xplains how you can use the Vuforia-Unity API to retireve the list of all the active Trackables at any given time, i.e. the list of those Trackables (Image Targets, Multi-Targets, Frame Markers, or other types) that are currently being tracked by Vuforia.

Note: the active Trackables typically correspond to the physical targets that are currently visible in the camera view (and that Vuforia has detected so far); however, when using Extended Tracking mode, a Trackable may be tracked even if it is temporarily outside the camera field of view.

Steps:

  • create a C# script, e.g. called TrackableList.cs
  • attach the script to the ARCamera in your Unity scene
  • implement the script along the lines of the following example:
public class TrackableList : MonoBehaviour {

    // Update is called once per frame
    void Update () {
        // Get the Vuforia StateManager
        StateManager sm = TrackerManager.Instance.GetStateManager ();

        // Query the StateManager to retrieve the list of
        // currently 'active' trackables 
        //(i.e. the ones currently being tracked by Vuforia)
        IEnumerable<TrackableBehaviour> activeTrackables = sm.GetActiveTrackableBehaviours ();

       // Iterate through the list of active trackables
        Debug.Log ("List of trackables currently active (tracked): ");
        foreach (TrackableBehaviour tb in activeTrackables) {
            Debug.Log("Trackable: " + tb.TrackableName);
        }
    }
}

Note: in the example above, we have put the relevant code in the Update() method of the script, as this will be executed at every frame; however, feel free to put the code wherever you deem necessary and meaningful for your specific application logic.