docs.unity3d.com
Search Results for

    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 communicate to the same session and will conflict with each other.

    Enabling or disabling the ARSession starts or stops the session, respectively.

    Inheritance
    object
    Object
    Component
    Behaviour
    MonoBehaviour
    SubsystemLifecycleManager<XRSessionSubsystem, XRSessionSubsystemDescriptor, XRSessionSubsystem.Provider>
    ARSession
    Inherited Members
    SubsystemLifecycleManager<XRSessionSubsystem, XRSessionSubsystemDescriptor, XRSessionSubsystem.Provider>.subsystem
    SubsystemLifecycleManager<XRSessionSubsystem, XRSessionSubsystemDescriptor, XRSessionSubsystem.Provider>.descriptor
    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.ReferenceEquals(object, object)
    Namespace: UnityEngine.XR.ARFoundation
    Assembly: Unity.XR.ARFoundation.dll
    Syntax
    [DisallowMultipleComponent]
    [DefaultExecutionOrder(-2147483648)]
    public sealed class ARSession : SubsystemLifecycleManager<XRSessionSubsystem, XRSessionSubsystemDescriptor, XRSessionSubsystem.Provider>

    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
    bool

    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
    int?

    matchFrameRateEnabled

    If true, the underlying subsystem will attempt to synchronize the AR frame rate with Unity's.

    Declaration
    public bool matchFrameRateEnabled { get; }
    Property Value
    Type Description
    bool
    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
    bool
    Remarks

    If enabled with a simple scene, the ARSession.Update might appear to take a long time. This is because your application is 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 smaller 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 AR Session 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 can 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 can 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 start the installation, and the state must not be Unsupported or this method will throw InvalidOperationException.

    Exceptions
    Type Condition
    InvalidOperationException

    Thrown if state is None or Unsupported.

    OnDestroy()

    Invoked when this MonoBehaviour is destroyed. Affects the state.

    Declaration
    protected override void OnDestroy()
    Overrides
    SubsystemLifecycleManager<XRSessionSubsystem, XRSessionSubsystemDescriptor, XRSessionSubsystem.Provider>.OnDestroy()

    OnDisable()

    Invoked when this MonoBehaviour is disabled. Affects the state.

    Declaration
    protected override void OnDisable()
    Overrides
    SubsystemLifecycleManager<XRSessionSubsystem, XRSessionSubsystemDescriptor, XRSessionSubsystem.Provider>.OnDisable()

    OnEnable()

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

    Declaration
    protected override void OnEnable()
    Overrides
    SubsystemLifecycleManager<XRSessionSubsystem, XRSessionSubsystemDescriptor, XRSessionSubsystem.Provider>.OnEnable()

    Reset()

    Resets the AR Session.

    Declaration
    public void Reset()
    Remarks

    Resetting the session destroys all trackables and resets device tracking (for example, 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>
    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)