using System; using UnityEngine.XR.ARSubsystems; namespace UnityEngine.XR.ARFoundation { /// /// The base class for all types. /// /// /// A "trackable" is something that is tracked in the physical environment. These include: /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// public abstract class ARTrackable : MonoBehaviour { } /// /// A generic component for trackables. A "trackable" is a feature in the physical /// environment that can be detected and tracked by an XR device. /// /// The raw, session-relative data type used to update this trackable. /// The concrete class which derives from . public class ARTrackable : ARTrackable where TSessionRelativeData : struct, ITrackable where TTrackable : ARTrackable { [SerializeField] [Tooltip("If true, this component's GameObject will be removed immediately when this trackable is removed.")] bool m_DestroyOnRemoval = true; /// /// If true, this component's GameObject will be removed immediately when the XR device reports this trackable is no longer tracked. /// /// /// Setting this to false will keep the GameObject around. You might want to do this, for example, /// if you have custom removal logic, such as a fade out. /// public bool destroyOnRemoval { get => m_DestroyOnRemoval; set => m_DestroyOnRemoval = value; } /// /// The TrackableId associated with this trackable. TrackableIds /// are typically unique to a particular session. /// public TrackableId trackableId => sessionRelativeData.trackableId; /// /// The tracking state associated with this trackable. /// public TrackingState trackingState => sessionRelativeData.trackingState; /// /// Pending means the trackable was added manually (usually via an AddTrackable-style method /// on its manager) but has not yet been reported as added. /// public bool pending { get; internal set; } /// /// The session-relative data associated with this trackable. /// protected TSessionRelativeData sessionRelativeData { get; private set; } /// /// Invoked just after the session-relative data has been set. /// The GameObject's transform has already been updated. /// You may override this method to perform further updates specific /// to the derived trackable. /// protected internal virtual void OnAfterSetSessionRelativeData() { } internal void SetSessionRelativeData(TSessionRelativeData data) => sessionRelativeData = data; internal Pose sessionRelativePose => sessionRelativeData.pose; } }