docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class ARTrackableManager<TSubsystem, TSubsystemDescriptor, TProvider, TSessionRelativeData, TTrackable>

    A base class for trackable managers. Trackable managers use data from tracking subsystems to create and maintain trackable components and their GameObjects. Refer to Trackables and trackable managers for more information.

    Inheritance
    object
    Object
    Component
    Behaviour
    MonoBehaviour
    SubsystemLifecycleManager<TSubsystem, TSubsystemDescriptor, TProvider>
    ARTrackableManager<TSubsystem, TSubsystemDescriptor, TProvider, TSessionRelativeData, TTrackable>
    ARAnchorManager
    ARBoundingBoxManager
    AREnvironmentProbeManager
    ARFaceManager
    ARHumanBodyManager
    ARParticipantManager
    ARPlaneManager
    ARPointCloudManager
    ARRaycastManager
    ARTrackedImageManager
    ARTrackedObjectManager
    Implements
    ITrackablesChanged<TTrackable>
    Inherited Members
    SubsystemLifecycleManager<TSubsystem, TSubsystemDescriptor, TProvider>.subsystem
    SubsystemLifecycleManager<TSubsystem, TSubsystemDescriptor, TProvider>.descriptor
    SubsystemLifecycleManager<TSubsystem, TSubsystemDescriptor, TProvider>.GetActiveSubsystemInstance()
    SubsystemLifecycleManager<TSubsystem, TSubsystemDescriptor, TProvider>.EnsureSubsystemInstanceSet()
    SubsystemLifecycleManager<TSubsystem, TSubsystemDescriptor, TProvider>.OnEnable()
    SubsystemLifecycleManager<TSubsystem, TSubsystemDescriptor, TProvider>.OnDisable()
    SubsystemLifecycleManager<TSubsystem, TSubsystemDescriptor, TProvider>.OnDestroy()
    SubsystemLifecycleManager<TSubsystem, TSubsystemDescriptor, TProvider>.OnBeforeStart()
    SubsystemLifecycleManager<TSubsystem, TSubsystemDescriptor, TProvider>.OnAfterStart()
    MonoBehaviour.IsInvoking()
    MonoBehaviour.CancelInvoke()
    MonoBehaviour.Invoke(string, float)
    MonoBehaviour.InvokeRepeating(string, float, float)
    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.destroyCancellationToken
    MonoBehaviour.useGUILayout
    MonoBehaviour.didStart
    MonoBehaviour.didAwake
    MonoBehaviour.runInEditMode
    Behaviour.enabled
    Behaviour.isActiveAndEnabled
    Component.GetComponent(Type)
    Component.GetComponent<T>()
    Component.TryGetComponent(Type, out Component)
    Component.TryGetComponent<T>(out T)
    Component.GetComponent(string)
    Component.GetComponentInChildren(Type, bool)
    Component.GetComponentInChildren(Type)
    Component.GetComponentInChildren<T>(bool)
    Component.GetComponentInChildren<T>()
    Component.GetComponentsInChildren(Type, bool)
    Component.GetComponentsInChildren(Type)
    Component.GetComponentsInChildren<T>(bool)
    Component.GetComponentsInChildren<T>(bool, List<T>)
    Component.GetComponentsInChildren<T>()
    Component.GetComponentsInChildren<T>(List<T>)
    Component.GetComponentInParent(Type, bool)
    Component.GetComponentInParent(Type)
    Component.GetComponentInParent<T>(bool)
    Component.GetComponentInParent<T>()
    Component.GetComponentsInParent(Type, bool)
    Component.GetComponentsInParent(Type)
    Component.GetComponentsInParent<T>(bool)
    Component.GetComponentsInParent<T>(bool, List<T>)
    Component.GetComponentsInParent<T>()
    Component.GetComponents(Type)
    Component.GetComponents(Type, List<Component>)
    Component.GetComponents<T>(List<T>)
    Component.GetComponents<T>()
    Component.GetComponentIndex()
    Component.CompareTag(string)
    Component.CompareTag(TagHandle)
    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
    Object.GetInstanceID()
    Object.GetHashCode()
    Object.Equals(object)
    Object.InstantiateAsync<T>(T)
    Object.InstantiateAsync<T>(T, Transform)
    Object.InstantiateAsync<T>(T, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, int)
    Object.InstantiateAsync<T>(T, int, Transform)
    Object.InstantiateAsync<T>(T, int, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, int, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>)
    Object.InstantiateAsync<T>(T, int, Transform, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, int, Transform, Vector3, Quaternion, CancellationToken)
    Object.InstantiateAsync<T>(T, int, Transform, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>)
    Object.InstantiateAsync<T>(T, int, Transform, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>, CancellationToken)
    Object.Instantiate(Object, Vector3, Quaternion)
    Object.Instantiate(Object, Vector3, Quaternion, Transform)
    Object.Instantiate(Object)
    Object.Instantiate(Object, Scene)
    Object.Instantiate(Object, Transform)
    Object.Instantiate(Object, Transform, bool)
    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, bool)
    Object.Destroy(Object, float)
    Object.Destroy(Object)
    Object.DestroyImmediate(Object, bool)
    Object.DestroyImmediate(Object)
    Object.FindObjectsOfType(Type)
    Object.FindObjectsOfType(Type, bool)
    Object.FindObjectsByType(Type, FindObjectsSortMode)
    Object.FindObjectsByType(Type, FindObjectsInactive, FindObjectsSortMode)
    Object.DontDestroyOnLoad(Object)
    Object.DestroyObject(Object, float)
    Object.DestroyObject(Object)
    Object.FindSceneObjectsOfType(Type)
    Object.FindObjectsOfTypeIncludingAssets(Type)
    Object.FindObjectsOfType<T>()
    Object.FindObjectsByType<T>(FindObjectsSortMode)
    Object.FindObjectsOfType<T>(bool)
    Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
    Object.FindObjectOfType<T>()
    Object.FindObjectOfType<T>(bool)
    Object.FindFirstObjectByType<T>()
    Object.FindAnyObjectByType<T>()
    Object.FindFirstObjectByType<T>(FindObjectsInactive)
    Object.FindAnyObjectByType<T>(FindObjectsInactive)
    Object.FindObjectsOfTypeAll(Type)
    Object.FindObjectOfType(Type)
    Object.FindFirstObjectByType(Type)
    Object.FindAnyObjectByType(Type)
    Object.FindObjectOfType(Type, bool)
    Object.FindFirstObjectByType(Type, FindObjectsInactive)
    Object.FindAnyObjectByType(Type, FindObjectsInactive)
    Object.ToString()
    Object.name
    Object.hideFlags
    object.Equals(object, object)
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: UnityEngine.XR.ARFoundation
    Assembly: Unity.XR.ARFoundation.dll
    Syntax
    [RequireComponent(typeof(XROrigin))]
    [DisallowMultipleComponent]
    public abstract class ARTrackableManager<TSubsystem, TSubsystemDescriptor, TProvider, TSessionRelativeData, TTrackable> : SubsystemLifecycleManager<TSubsystem, TSubsystemDescriptor, TProvider>, ITrackablesChanged<TTrackable> where TSubsystem : TrackingSubsystem<TSessionRelativeData, TSubsystem, TSubsystemDescriptor, TProvider>, new() where TSubsystemDescriptor : SubsystemDescriptorWithProvider<TSubsystem, TProvider> where TProvider : SubsystemProvider<TSubsystem> where TSessionRelativeData : struct, ITrackable where TTrackable : ARTrackable<TSessionRelativeData, TTrackable>
    Type Parameters
    Name Description
    TSubsystem

    The tracking subsystem type.

    TSubsystemDescriptor

    The subsystem descriptor type.

    TProvider

    The subsystem provider type.

    TSessionRelativeData

    The subsystem data type.

    TTrackable

    The type of component that this component will manage (that is, create, update, and destroy).

    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

    origin

    The XR Origin component that will be used to instantiate detected trackables.

    Declaration
    protected XROrigin origin { get; }
    Property Value
    Type Description
    XROrigin

    trackables

    A collection of all trackables managed by this component.

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

    trackablesChanged

    Invoked when trackables have changed (been added, updated, or removed).

    Declaration
    public UnityEvent<ARTrackablesChangedEventArgs<TTrackable>> trackablesChanged { get; }
    Property Value
    Type Description
    UnityEvent<ARTrackablesChangedEventArgs<TTrackable>>

    Methods

    Awake()

    Saves a reference to the XR Origin component.

    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 trackable to add to the subsystem.

    Returns
    Type Description
    bool

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

    Remarks

    If trackable has not been reported as added yet, and this component 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> added with a call to AddComponent, for example.

    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.

    CreateTrackableImmediate(TSessionRelativeData)

    Creates a TTrackable immediately in a "pending" state. The trackable will appear in the trackables collection immediately, but will not be reported as added until the subsystem successfully adds it. This is useful for subsystems that deal with trackables that can be both automatically detected and manually created.

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

    The data associated with the trackable.

    Returns
    Type Description
    TTrackable

    A new trackable.

    DestroyPendingTrackable(TrackableId)

    If the trackable with id trackableId is 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
    bool

    true if the trackable was "pending" and is now destroyed. Otherwise, false.

    Remarks

    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 might 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.

    GetPrefab()

    The Prefab that should be instantiated when adding a trackable. Can 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 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
    SubsystemLifecycleManager<TSubsystem, TSubsystemDescriptor, TProvider>.OnDisable()

    OnEnable()

    Creates the TSubsystem.

    Declaration
    protected override void OnEnable()
    Overrides
    SubsystemLifecycleManager<TSubsystem, TSubsystemDescriptor, TProvider>.OnEnable()

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

    Invoked when trackables have changed (that is, they were added, updated, or removed). Use this to perform additional logic, or to invoke public events related to your trackables.

    Declaration
    [Obsolete("OnTrackablesChanged() has been deprecated in AR Foundation version 6.0.", false)]
    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(bool)

    Iterates over every instantiated ARTrackable<TSessionRelativeData, TTrackable> and activates or deactivates its GameObject based on the value of active.

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

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

    Update()

    Update is called once per frame. This component first updates its internal state, then invokes the trackablesChanged event.

    Declaration
    protected virtual void Update()

    Implements

    ITrackablesChanged<TTrackable>
    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)