Class ARTrackableManager<TSubsystem, TSubsystemDescriptor, TSessionRelativeData, TTrackable> | Package Manager UI website
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
    System.Object
    SubsystemLifecycleManager<TSubsystem, TSubsystemDescriptor>
    ARTrackableManager<TSubsystem, TSubsystemDescriptor, TSessionRelativeData, TTrackable>
    ARPlaneManager
    ARPointCloudManager
    ARReferencePointManager
    Inherited Members
    SubsystemLifecycleManager<TSubsystem, TSubsystemDescriptor>.subsystem
    SubsystemLifecycleManager<TSubsystem, TSubsystemDescriptor>.CreateSubsystem()
    SubsystemLifecycleManager<TSubsystem, TSubsystemDescriptor>.CreateSubsystemIfNecessary()
    SubsystemLifecycleManager<TSubsystem, TSubsystemDescriptor>.OnEnable()
    SubsystemLifecycleManager<TSubsystem, TSubsystemDescriptor>.OnDisable()
    SubsystemLifecycleManager<TSubsystem, TSubsystemDescriptor>.OnDestroy()
    SubsystemLifecycleManager<TSubsystem, TSubsystemDescriptor>.OnBeforeStart()
    SubsystemLifecycleManager<TSubsystem, TSubsystemDescriptor>.OnAfterStart()
    Namespace: UnityEngine.XR.ARFoundation
    Syntax
    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 is not null, then that prefab will be instantiated.

    Fields

    m_PendingAdds

    A dictionary of trackables added via CreateImmedate but not yet reported as added.

    Declaration
    protected Dictionary<TrackableId, TTrackable> m_PendingAdds
    Field Value
    Type Description
    System.Collections.Generic.Dictionary<TrackableId, TTrackable>

    m_Trackables

    A dictionary of all trackables, keyed by TrackableId.

    Declaration
    protected Dictionary<TrackableId, TTrackable> m_Trackables
    Field Value
    Type Description
    System.Collections.Generic.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
    System.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()

    CreateTrackableImmediate(TSessionRelativeData)

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

    DestroyPendingTrackable(TrackableId)

    If in a "pending" state, the trackable with trackableId's event is invoked, and the trackable's GameObject destroyed if destroyOnRemoval is true. Otherwise, this method has no effect.

    Declaration
    protected bool DestroyPendingTrackable(TrackableId trackableId)
    Parameters
    Type Name Description
    TrackableId trackableId
    Returns
    Type Description
    System.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"). However, this method does invoke on the trackable.

    GetPrefab()

    The prefab that should be instantiated when adding a trackable.

    Declaration
    protected virtual GameObject GetPrefab()
    Returns
    Type Description
    GameObject

    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.

    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
    System.Collections.Generic.List<TTrackable> added

    A list of trackables added this frame.

    System.Collections.Generic.List<TTrackable> updated

    A list of trackables updated this frame.

    System.Collections.Generic.List<TTrackable> removed

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

    Update()

    Update is called once per frame. This component's internal state is first updated, and then the event is invoked.

    Declaration
    protected virtual void Update()
    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