docs.unity3d.com
    Show / Hide Table of Contents

    AR tracked object manager

    The tracked object manager is a type of trackable manager.

    AR tracked object manager

    The tracked object manager creates GameObjects for each detected object in the environment. Before an object can be detected, the manager must be instructed to look for a set of reference objects compiled into a reference image library. It only detects objects in this library.

    Reference library

    For instructions on how to create a reference object library, see documentation on the Tracked Object Subsystem.

    The reference object library can be set at runtime, but as long as the tracked object manager component is enabled, the reference object library must be non-null.

    The reference object library is an instance of the ScriptableObject XRReferenceImageLibrary. This object contains mostly Editor data. The actual library data (containing the object data) is provider-specific. Refer to your provider's documentation for details.

    Creating a manager at runtime

    When you add a component to an active GameObject at runtime, Unity immediately invokes its OnEnable method. However, the ARTrackedObjectManager requires a non-null reference object library. If the reference object library is null when the ARTrackedObjectManager is enabled, it will automatically disable itself.

    To add an ARTrackedObjectManager at runtime, set its reference object library and then re-enable it:

    var manager = gameObject.AddComponent<ARTrackedObjectManager>();
    manager.referenceLibrary = myLibrary;
    manager.enabled = true;
    

    Tracked object prefab

    This prefab is instantiated whenever an object from the reference object library is detected. The manager ensures the instantiated GameObject includes an ARTrackedObject component. You can get the reference object that was used to detect the ARTrackedObject with the ARTrackedObject.referenceObject property.

    In This Article
    • Reference library
    • Creating a manager at runtime
    • Tracked object prefab
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023