docs.unity3d.com
    Show / Hide Table of Contents

    Class ARSession

    Controls the lifecycle and configuration options for an AR session. There is only one active session. If you have multiple ARSession components, they all talk to the same session and will conflict with each other.

    Enabling or disabling the ARSession will start or stop the session, respectively.

    Inheritance
    Object
    Object
    Component
    Behaviour
    MonoBehaviour
    SubsystemLifecycleManager<XRSessionSubsystem, XRSessionSubsystemDescriptor>
    ARSession
    Inherited Members
    SubsystemLifecycleManager<XRSessionSubsystem, XRSessionSubsystemDescriptor>.subsystem
    SubsystemLifecycleManager<XRSessionSubsystem, XRSessionSubsystemDescriptor>.descriptor
    SubsystemLifecycleManager<XRSessionSubsystem, XRSessionSubsystemDescriptor>.GetActiveSubsystemInstance()
    SubsystemLifecycleManager<XRSessionSubsystem, XRSessionSubsystemDescriptor>.EnsureSubsystemInstanceSet()
    SubsystemLifecycleManager<XRSessionSubsystem, XRSessionSubsystemDescriptor>.OnEnable()
    SubsystemLifecycleManager<XRSessionSubsystem, XRSessionSubsystemDescriptor>.OnDisable()
    SubsystemLifecycleManager<XRSessionSubsystem, XRSessionSubsystemDescriptor>.OnDestroy()
    SubsystemLifecycleManager<XRSessionSubsystem, XRSessionSubsystemDescriptor>.OnBeforeStart()
    SubsystemLifecycleManager<XRSessionSubsystem, XRSessionSubsystemDescriptor>.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
    [DisallowMultipleComponent]
    [DefaultExecutionOrder(-2147483648)]
    [HelpURL("https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@4.1/api/UnityEngine.XR.ARFoundation.ARSession.html")]
    public sealed class ARSession : SubsystemLifecycleManager<XRSessionSubsystem, XRSessionSubsystemDescriptor>

    Properties

    attemptUpdate

    If the device supports XR but does not have the necessary software, some platforms allow prompting the user to install or update the software. If attemptUpdate is true, a software update will be attempted. If the appropriate software is not installed or out of date, and attemptUpdate is false, then AR will not be available.

    Declaration
    public bool attemptUpdate { get; set; }
    Property Value
    Type Description
    Boolean

    currentTrackingMode

    Get the current TrackingMode in use by the session.

    Declaration
    public TrackingMode currentTrackingMode { get; }
    Property Value
    Type Description
    TrackingMode

    frameRate

    Get the number of AR frames produced per second, or null if the frame rate cannot be determined.

    Declaration
    public int? frameRate { get; }
    Property Value
    Type Description
    Nullable<Int32>

    matchFrameRate

    If True, the session will block execution until a new AR frame is available. This property is obsolete. Use matchFrameRateRequested or matchFrameRateEnabled instead.

    Declaration
    [Obsolete("Use matchFrameRateRequested or matchFrameRateEnabled instead. (2020-01-28)")]
    public bool matchFrameRate { get; set; }
    Property Value
    Type Description
    Boolean

    matchFrameRateEnabled

    Whether the underlying subsystem will attempt to synchronize the AR frame rate with Unity's.

    Declaration
    public bool matchFrameRateEnabled { get; }
    Property Value
    Type Description
    Boolean
    See Also
    matchFrameRateRequested

    matchFrameRateRequested

    If true, the session will block execution until a new AR frame is available and set Application.targetFrameRate to match the native update frequency of the AR session. Otherwise, the AR session is updated independently of the Unity frame.

    Declaration
    public bool matchFrameRateRequested { get; set; }
    Property Value
    Type Description
    Boolean
    Remarks

    If enabled with a simple scene, the ARSession.Update may appear to take a long time. This is simply waiting for the next AR frame, similar to the way Unity will WaitForTargetFPS at the end of a frame. If the rest of the Unity frame takes non-trivial time, then the next ARSession.Update will take a proportionally less amount of time.

    This option does three things:

    • Enables a setting on the XRSessionSubsystem which causes the update to block until the next AR frame is ready
    • Sets Application.targetFrameRate to the session's preferred update rate
    • Sets QualitySettings.vSyncCount to zero

    These settings are not reverted when the ARSession is disabled.

    notTrackingReason

    The reason AR tracking was lost.

    Declaration
    public static NotTrackingReason notTrackingReason { get; }
    Property Value
    Type Description
    NotTrackingReason

    requestedTrackingMode

    Get or set the TrackingMode for the session.

    Declaration
    public TrackingMode requestedTrackingMode { get; set; }
    Property Value
    Type Description
    TrackingMode

    state

    The state of the entire system. Use this to determine the status of AR availability and installation.

    Declaration
    public static ARSessionState state { get; }
    Property Value
    Type Description
    ARSessionState

    Methods

    CheckAvailability()

    Start checking the availability of XR on the current device.

    Declaration
    public static IEnumerator CheckAvailability()
    Returns
    Type Description
    IEnumerator

    An IEnumerator used for a coroutine.

    Remarks

    The availability check may be asynchronous, so this is implemented as a coroutine. It is safe to call this multiple times; if called a second time while an availability check is being made, it returns a new coroutine which waits on the first.

    Install()

    Begin installing AR software on the current device (if supported).

    Declaration
    public static IEnumerator Install()
    Returns
    Type Description
    IEnumerator

    An IEnumerator used for a coroutine.

    Remarks

    Installation may be asynchronous, so this is implemented as a coroutine. It is safe to call this multiple times, but you must first call CheckAvailability().

    You must call CheckAvailability() before trying to Install and the state must not be Unsupported or this method will throw.

    OnDestroy()

    Invoked when this MonoBehaviour is destroyed. Used to affect the state.

    Declaration
    protected override void OnDestroy()
    Overrides
    UnityEngine.XR.ARFoundation.SubsystemLifecycleManager<UnityEngine.XR.ARSubsystems.XRSessionSubsystem, UnityEngine.XR.ARSubsystems.XRSessionSubsystemDescriptor>.OnDestroy()

    OnDisable()

    Invoked when this MonoBehaviour is disabled. Used to affect the state.

    Declaration
    protected override void OnDisable()
    Overrides
    UnityEngine.XR.ARFoundation.SubsystemLifecycleManager<UnityEngine.XR.ARSubsystems.XRSessionSubsystem, UnityEngine.XR.ARSubsystems.XRSessionSubsystemDescriptor>.OnDisable()

    OnEnable()

    Creates and initializes the session subsystem. Begins checking for availability.

    Declaration
    protected override void OnEnable()
    Overrides
    UnityEngine.XR.ARFoundation.SubsystemLifecycleManager<UnityEngine.XR.ARSubsystems.XRSessionSubsystem, UnityEngine.XR.ARSubsystems.XRSessionSubsystemDescriptor>.OnEnable()

    Reset()

    Resets the AR Session.

    Declaration
    public void Reset()
    Remarks

    Resetting the session destroys all trackables and resets device tracking (e.g., the position of the session is reset to the origin).

    Events

    stateChanged

    This event is invoked whenever the state changes.

    Declaration
    public static event Action<ARSessionStateChangedEventArgs> stateChanged
    Event Type
    Type Description
    Action<ARSessionStateChangedEventArgs>
    Back to top Copyright © 2022 Unity Technologies
    Generated by DocFX
    on Monday, November 7, 2022
    Terms of use