docs.unity3d.com
    Show / Hide Table of Contents

    Class ARTrackableManager<TSubsystem, TSubsystemDescriptor, TSessionRelativeData, TTrackable>

    A generic manager for components generated by features detected in the physical environment.

    Inheritance
    Object
    Object
    Component
    Behaviour
    MonoBehaviour
    SubsystemLifecycleManager<TSubsystem, TSubsystemDescriptor>
    ARTrackableManager<TSubsystem, TSubsystemDescriptor, TSessionRelativeData, TTrackable>
    ARAnchorManager
    AREnvironmentProbeManager
    ARFaceManager
    ARHumanBodyManager
    ARParticipantManager
    ARPlaneManager
    ARPointCloudManager
    ARRaycastManager
    ARReferencePointManager
    ARTrackedImageManager
    ARTrackedObjectManager
    Inherited Members
    SubsystemLifecycleManager<TSubsystem, TSubsystemDescriptor>.subsystem
    SubsystemLifecycleManager<TSubsystem, TSubsystemDescriptor>.descriptor
    SubsystemLifecycleManager<TSubsystem, TSubsystemDescriptor>.GetActiveSubsystemInstance()
    SubsystemLifecycleManager<TSubsystem, TSubsystemDescriptor>.EnsureSubsystemInstanceSet()
    SubsystemLifecycleManager<TSubsystem, TSubsystemDescriptor>.OnEnable()
    SubsystemLifecycleManager<TSubsystem, TSubsystemDescriptor>.OnDisable()
    SubsystemLifecycleManager<TSubsystem, TSubsystemDescriptor>.OnDestroy()
    SubsystemLifecycleManager<TSubsystem, TSubsystemDescriptor>.OnBeforeStart()
    SubsystemLifecycleManager<TSubsystem, TSubsystemDescriptor>.OnAfterStart()
    MonoBehaviour.IsInvoking()
    MonoBehaviour.CancelInvoke()
    MonoBehaviour.Invoke(String, Single)
    MonoBehaviour.InvokeRepeating(String, Single, Single)
    MonoBehaviour.CancelInvoke(String)
    MonoBehaviour.IsInvoking(String)
    MonoBehaviour.StartCoroutine(String)
    MonoBehaviour.StartCoroutine(String, Object)
    MonoBehaviour.StartCoroutine(IEnumerator)
    MonoBehaviour.StartCoroutine_Auto(IEnumerator)
    MonoBehaviour.StopCoroutine(IEnumerator)
    MonoBehaviour.StopCoroutine(Coroutine)
    MonoBehaviour.StopCoroutine(String)
    MonoBehaviour.StopAllCoroutines()
    MonoBehaviour.print(Object)
    MonoBehaviour.useGUILayout
    MonoBehaviour.runInEditMode
    Behaviour.enabled
    Behaviour.isActiveAndEnabled
    Component.GetComponent(Type)
    Component.GetComponent<T>()
    Component.TryGetComponent(Type, Component)
    Component.TryGetComponent<T>(T)
    Component.GetComponent(String)
    Component.GetComponentInChildren(Type, Boolean)
    Component.GetComponentInChildren(Type)
    Component.GetComponentInChildren<T>(Boolean)
    Component.GetComponentInChildren<T>()
    Component.GetComponentsInChildren(Type, Boolean)
    Component.GetComponentsInChildren(Type)
    Component.GetComponentsInChildren<T>(Boolean)
    Component.GetComponentsInChildren<T>(Boolean, List<T>)
    Component.GetComponentsInChildren<T>()
    Component.GetComponentsInChildren<T>(List<T>)
    Component.GetComponentInParent(Type)
    Component.GetComponentInParent<T>()
    Component.GetComponentsInParent(Type, Boolean)
    Component.GetComponentsInParent(Type)
    Component.GetComponentsInParent<T>(Boolean)
    Component.GetComponentsInParent<T>(Boolean, List<T>)
    Component.GetComponentsInParent<T>()
    Component.GetComponents(Type)
    Component.GetComponents(Type, List<Component>)
    Component.GetComponents<T>(List<T>)
    Component.GetComponents<T>()
    Component.CompareTag(String)
    Component.SendMessageUpwards(String, Object, SendMessageOptions)
    Component.SendMessageUpwards(String, Object)
    Component.SendMessageUpwards(String)
    Component.SendMessageUpwards(String, SendMessageOptions)
    Component.SendMessage(String, Object)
    Component.SendMessage(String)
    Component.SendMessage(String, Object, SendMessageOptions)
    Component.SendMessage(String, SendMessageOptions)
    Component.BroadcastMessage(String, Object, SendMessageOptions)
    Component.BroadcastMessage(String, Object)
    Component.BroadcastMessage(String)
    Component.BroadcastMessage(String, SendMessageOptions)
    Component.transform
    Component.gameObject
    Component.tag
    Component.rigidbody
    Component.rigidbody2D
    Component.camera
    Component.light
    Component.animation
    Component.constantForce
    Component.renderer
    Component.audio
    Component.networkView
    Component.collider
    Component.collider2D
    Component.hingeJoint
    Component.particleSystem
    Object.GetInstanceID()
    Object.GetHashCode()
    Object.Equals(Object)
    Object.Instantiate(Object, Vector3, Quaternion)
    Object.Instantiate(Object, Vector3, Quaternion, Transform)
    Object.Instantiate(Object)
    Object.Instantiate(Object, Transform)
    Object.Instantiate(Object, Transform, Boolean)
    Object.Instantiate<T>(T)
    Object.Instantiate<T>(T, Vector3, Quaternion)
    Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
    Object.Instantiate<T>(T, Transform)
    Object.Instantiate<T>(T, Transform, Boolean)
    Object.Destroy(Object, Single)
    Object.Destroy(Object)
    Object.DestroyImmediate(Object, Boolean)
    Object.DestroyImmediate(Object)
    Object.FindObjectsOfType(Type)
    Object.DontDestroyOnLoad(Object)
    Object.DestroyObject(Object, Single)
    Object.DestroyObject(Object)
    Object.FindSceneObjectsOfType(Type)
    Object.FindObjectsOfTypeIncludingAssets(Type)
    Object.FindObjectsOfType<T>()
    Object.FindObjectOfType<T>()
    Object.FindObjectsOfTypeAll(Type)
    Object.FindObjectOfType(Type)
    Object.ToString()
    Object.name
    Object.hideFlags
    Namespace: UnityEngine.XR.ARFoundation
    Syntax
    [RequireComponent(typeof(ARSessionOrigin))]
    [DisallowMultipleComponent]
    public abstract class ARTrackableManager<TSubsystem, TSubsystemDescriptor, TSessionRelativeData, TTrackable> : SubsystemLifecycleManager<TSubsystem, TSubsystemDescriptor> where TSubsystem : TrackingSubsystem<TSessionRelativeData, TSubsystemDescriptor> where TSubsystemDescriptor : SubsystemDescriptor<TSubsystem> where TSessionRelativeData : struct, ITrackable where TTrackable : ARTrackable<TSessionRelativeData, TTrackable>
    Type Parameters
    Name Description
    TSubsystem

    The Subsystem which provides this manager data.

    TSubsystemDescriptor

    The SubsystemDescriptor required to create the Subsystem.

    TSessionRelativeData

    A concrete struct used to hold data provided by the Subsystem.

    TTrackable

    The type of component this component will manage (i.e., create, update, and destroy).

    Remarks

    When the manager is informed that a trackable has been added, a new GameObject is created with an ARTrackable component on it. If ARTrackableManager<TSubsystem, TSubsystemDescriptor, TSessionRelativeData, TTrackable> is not null, then that prefab will be instantiated.

    Fields

    m_PendingAdds

    A dictionary of trackables added via CreateTrackableImmediate(TSessionRelativeData) but not yet reported as added.

    Declaration
    protected Dictionary<TrackableId, TTrackable> m_PendingAdds
    Field Value
    Type Description
    Dictionary<TrackableId, TTrackable>

    m_Trackables

    A dictionary of all trackables, keyed by TrackableId.

    Declaration
    protected Dictionary<TrackableId, TTrackable> m_Trackables
    Field Value
    Type Description
    Dictionary<TrackableId, TTrackable>

    Properties

    gameObjectName

    The name prefix that should be used when instantiating new GameObjects.

    Declaration
    protected abstract string gameObjectName { get; }
    Property Value
    Type Description
    String

    sessionOrigin

    The ARSessionOrigin which will be used to instantiate detected trackables.

    Declaration
    protected ARSessionOrigin sessionOrigin { get; }
    Property Value
    Type Description
    ARSessionOrigin

    trackables

    A collection of all trackables managed by this component.

    Declaration
    public TrackableCollection<TTrackable> trackables { get; }
    Property Value
    Type Description
    TrackableCollection<TTrackable>

    Methods

    Awake()

    Invoked by Unity once when this component wakes up.

    Declaration
    protected virtual void Awake()

    CanBeAddedToSubsystem(TTrackable)

    Determines whether an existing ARTrackable<TSessionRelativeData, TTrackable> can be added to the underlying subsystem.

    Declaration
    protected bool CanBeAddedToSubsystem(TTrackable trackable)
    Parameters
    Type Name Description
    TTrackable trackable

    An existing ARTrackable<TSessionRelativeData, TTrackable> to add to the underlying subsystem.

    Returns
    Type Description
    Boolean

    Returns true if this manager is enabled, has a valid subsystem, and trackable is not already being tracked by this manager. Returns false otherwise.

    Remarks

    If trackable has not been added yet (i.e., it is not tracked by this manager) and the manager is either disabled or does not have a valid subsystem, then the trackable's pending state is set to true.

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown if trackable is null.

    CreateTrackableFromExisting(TTrackable, TSessionRelativeData)

    Creates the native counterpart for an existing ARTrackable<TSessionRelativeData, TTrackable> e.g., added with a call to AddComponent.

    Declaration
    protected void CreateTrackableFromExisting(TTrackable existingTrackable, TSessionRelativeData sessionRelativeData)
    Parameters
    Type Name Description
    TTrackable existingTrackable

    The existing trackable component.

    TSessionRelativeData sessionRelativeData

    The AR data associated with the trackable. This usually comes from the trackable's associated subsystem

    CreateTrackableImmediate(TSessionRelativeData)

    Creates a TTrackable immediately, leaving it in a "pending" state.

    Declaration
    protected TTrackable CreateTrackableImmediate(TSessionRelativeData sessionRelativeData)
    Parameters
    Type Name Description
    TSessionRelativeData sessionRelativeData

    The data associated with the trackable. All spatial data should be relative to the ARSessionOrigin.

    Returns
    Type Description
    TTrackable

    A new TTrackable

    Remarks

    Trackables are usually created, updated, or destroyed during Update(). This method creates a trackable immediately, and marks it as "pending" until it is reported as added by the subsystem. This is useful for subsystems that deal with trackables that can be both detected and manually created.

    This method does not invoke OnTrackablesChanged(List<TTrackable>, List<TTrackable>, List<TTrackable>), so no "added" notifications will occur until the next call to Update().

    The trackable will appear in the trackables collection immediately.

    DestroyPendingTrackable(TrackableId)

    If in a "pending" state and destroyOnRemoval is true, this method destroys the trackable's GameObject. Otherwise, this method has no effect.

    Declaration
    protected bool DestroyPendingTrackable(TrackableId trackableId)
    Parameters
    Type Name Description
    TrackableId trackableId

    The id of the trackable to destroy.

    Returns
    Type Description
    Boolean

    True if the trackable is "pending" (i.e., not yet reported as "added").

    Remarks

    Trackables are usually removed only when the subsystem reports they have been removed during Update()

    This method will immediately remove a trackable only if it was created by CreateTrackableImmediate(TSessionRelativeData) and has not yet been reported as added by the subsystem.

    This can happen if the trackable is created and removed within the same frame, as the subsystem may never have a chance to report its existence. Derived classes should use this if they support the concept of manual addition and removal of trackables, as there may not be a removal event if the trackable is added and removed quickly.

    If the trackable is not in a pending state, i.e., it has already been reported as "added", then this method does nothing.

    This method does not invoke OnTrackablesChanged(List<TTrackable>, List<TTrackable>, List<TTrackable>), so no "removed" notifications will occur until the next call to Update() (and only if it was previously reported as "added").

    GetPrefab()

    The prefab that should be instantiated when adding a trackable. May be null.

    Declaration
    protected virtual GameObject GetPrefab()
    Returns
    Type Description
    GameObject

    The prefab should be instantiated when adding a trackable.

    OnAfterSetSessionRelativeData(TTrackable, TSessionRelativeData)

    Invoked just after session relative data has been set on a trackable.

    Declaration
    protected virtual void OnAfterSetSessionRelativeData(TTrackable trackable, TSessionRelativeData sessionRelativeData)
    Parameters
    Type Name Description
    TTrackable trackable

    The trackable that has just been updated.

    TSessionRelativeData sessionRelativeData

    The session relative data used to update the trackable.

    OnCreateTrackable(TTrackable)

    Invoked after creating the trackable. The trackable's sessionRelativeData property will already be set.

    Declaration
    protected virtual void OnCreateTrackable(TTrackable trackable)
    Parameters
    Type Name Description
    TTrackable trackable

    The newly created trackable.

    OnDisable()

    Stops the TSubsystem.

    Declaration
    protected override void OnDisable()
    Overrides
    UnityEngine.XR.ARFoundation.SubsystemLifecycleManager<TSubsystem, TSubsystemDescriptor>.OnDisable()

    OnEnable()

    Creates the TSubsystem.

    Declaration
    protected override void OnEnable()
    Overrides
    UnityEngine.XR.ARFoundation.SubsystemLifecycleManager<TSubsystem, TSubsystemDescriptor>.OnEnable()

    OnTrackablesChanged(List<TTrackable>, List<TTrackable>, List<TTrackable>)

    Invoked when trackables have changed, i.e., added, updated, or removed. Use this to perform additional logic, or to invoke public events related to your trackables.

    Declaration
    protected virtual void OnTrackablesChanged(List<TTrackable> added, List<TTrackable> updated, List<TTrackable> removed)
    Parameters
    Type Name Description
    List<TTrackable> added

    A list of trackables added this frame.

    List<TTrackable> updated

    A list of trackables updated this frame.

    List<TTrackable> removed

    A list of trackables removed this frame. The trackable components are not destroyed until after this method returns.

    SetTrackablesActive(Boolean)

    Iterates over every instantiated ARTrackable<TSessionRelativeData, TTrackable> activates or deactivates its GameObject based on the value of active. This calls GameObject.SetActive on each trackable's GameObject.

    Declaration
    public void SetTrackablesActive(bool active)
    Parameters
    Type Name Description
    Boolean active

    If true each trackable's GameObject is activated. Otherwise, it is deactivated.

    Update()

    Update is called once per frame. This component's internal state is first updated, and then an event notifying whether any trackables have been added, removed, or updated is invoked by the derived manager.

    Declaration
    protected virtual void Update()
    Back to top Copyright © 2022 Unity Technologies
    Generated by DocFX
    on Monday, November 7, 2022
    Terms of use