docs.unity3d.com
    Show / Hide Table of Contents

    Class XRSessionSubsystem

    This subsystem controls the lifecycle of an XR session. Some platforms, particularly those that have non-XR modes, need to be able to turn the session on and off to enter and exit XR modes of operation.

    Inheritance
    Object
    UnityEngine.SubsystemsImplementation.SubsystemWithProvider
    UnityEngine.SubsystemsImplementation.SubsystemWithProvider<XRSessionSubsystem, XRSessionSubsystemDescriptor, XRSessionSubsystem.Provider>
    XRSessionSubsystem
    SimulationSessionSubsystem
    Inherited Members
    UnityEngine.SubsystemsImplementation.SubsystemWithProvider<UnityEngine.XR.ARSubsystems.XRSessionSubsystem, UnityEngine.XR.ARSubsystems.XRSessionSubsystemDescriptor, UnityEngine.XR.ARSubsystems.XRSessionSubsystem.Provider>.OnCreate()
    UnityEngine.SubsystemsImplementation.SubsystemWithProvider<UnityEngine.XR.ARSubsystems.XRSessionSubsystem, UnityEngine.XR.ARSubsystems.XRSessionSubsystemDescriptor, UnityEngine.XR.ARSubsystems.XRSessionSubsystem.Provider>.OnStart()
    UnityEngine.SubsystemsImplementation.SubsystemWithProvider<UnityEngine.XR.ARSubsystems.XRSessionSubsystem, UnityEngine.XR.ARSubsystems.XRSessionSubsystemDescriptor, UnityEngine.XR.ARSubsystems.XRSessionSubsystem.Provider>.OnStop()
    UnityEngine.SubsystemsImplementation.SubsystemWithProvider<UnityEngine.XR.ARSubsystems.XRSessionSubsystem, UnityEngine.XR.ARSubsystems.XRSessionSubsystemDescriptor, UnityEngine.XR.ARSubsystems.XRSessionSubsystem.Provider>.OnDestroy()
    UnityEngine.SubsystemsImplementation.SubsystemWithProvider<UnityEngine.XR.ARSubsystems.XRSessionSubsystem, UnityEngine.XR.ARSubsystems.XRSessionSubsystemDescriptor, UnityEngine.XR.ARSubsystems.XRSessionSubsystem.Provider>.subsystemDescriptor
    UnityEngine.SubsystemsImplementation.SubsystemWithProvider<UnityEngine.XR.ARSubsystems.XRSessionSubsystem, UnityEngine.XR.ARSubsystems.XRSessionSubsystemDescriptor, UnityEngine.XR.ARSubsystems.XRSessionSubsystem.Provider>.provider
    UnityEngine.SubsystemsImplementation.SubsystemWithProvider.Start()
    UnityEngine.SubsystemsImplementation.SubsystemWithProvider.OnStart()
    UnityEngine.SubsystemsImplementation.SubsystemWithProvider.Stop()
    UnityEngine.SubsystemsImplementation.SubsystemWithProvider.OnStop()
    UnityEngine.SubsystemsImplementation.SubsystemWithProvider.Destroy()
    UnityEngine.SubsystemsImplementation.SubsystemWithProvider.OnDestroy()
    UnityEngine.SubsystemsImplementation.SubsystemWithProvider.running
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: UnityEngine.XR.ARSubsystems
    Syntax
    public class XRSessionSubsystem : SubsystemWithProvider<XRSessionSubsystem, XRSessionSubsystemDescriptor, XRSessionSubsystem.Provider>, ISubsystem

    Constructors

    XRSessionSubsystem()

    Do not call this directly. Call create on a valid XRSessionSubsystemDescriptor instead.

    Declaration
    public XRSessionSubsystem()

    Properties

    configurationChooser

    Get or set the ConfigurationChooser used by DetermineConfiguration(Feature). If set to null, the DefaultConfigurationChooser is used.

    Declaration
    public ConfigurationChooser configurationChooser { get; set; }
    Property Value
    Type Description
    ConfigurationChooser

    currentConfiguration

    The current Configuration in use by the session.

    Declaration
    public Configuration? currentConfiguration { get; }
    Property Value
    Type Description
    Nullable<Configuration>
    See Also
    DetermineConfiguration(Feature)
    Feature

    currentTrackingMode

    Get the current tracking mode in use by the subsystem.

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

    frameRate

    The native update rate of the AR Session.

    Declaration
    public int frameRate { get; }
    Property Value
    Type Description
    Int32
    Exceptions
    Type Condition
    NotSupportedException

    Thrown if supportsMatchFrameRate is False.

    matchFrameRateEnabled

    Whether the AR session update is synchronized with the Unity frame rate. If true, Update(XRSessionUpdateParams) should block until the next AR frame is available.

    Declaration
    public bool matchFrameRateEnabled { get; }
    Property Value
    Type Description
    Boolean
    Exceptions
    Type Condition
    NotSupportedException

    Thrown if supportsMatchFrameRate is False.

    matchFrameRateRequested

    Get or set whether the match frame rate feature should be enabled. When enabled, the AR session update is synchronized with the Unity frame rate.

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

    nativePtr

    Returns an implementation-defined pointer associated with the session.

    Declaration
    public IntPtr nativePtr { get; }
    Property Value
    Type Description
    IntPtr

    notTrackingReason

    Gets the NotTrackingReason for the session.

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

    requestedFeatures

    Get the requested Features. These are used to determine the session's Configuration.

    Declaration
    public Feature requestedFeatures { get; }
    Property Value
    Type Description
    Feature
    See Also
    DetermineConfiguration(Feature)

    requestedTrackingMode

    The requested tracking mode. Query for support with SubsystemDescriptor.supportedTrackingModes.

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

    sessionId

    Returns a unique session identifier for this session.

    Declaration
    public Guid sessionId { get; }
    Property Value
    Type Description
    Guid

    trackingState

    Gets the TrackingState for the session.

    Declaration
    public TrackingState trackingState { get; }
    Property Value
    Type Description
    TrackingState

    Methods

    DetermineConfiguration(Feature)

    Determines the Configuration the session will use given the requested features.

    Declaration
    public Configuration? DetermineConfiguration(Feature features)
    Parameters
    Type Name Description
    Feature features

    A set of requested Features.

    Returns
    Type Description
    Nullable<Configuration>

    The Configuration the session would use given the requested features, or null if configuration introspection is not available.

    Remarks

    This method uses the current configurationChooser to choose a configuration using the requested features and the capabilities of the available configurations. The configuration chooser is customizable, see ConfigurationChooser. If you do not set a configuration chooser, the DefaultConfigurationChooser is used.

    You can use this method to determine what would happen if you were to enable or disable a particular feature. For example, you can use this method to determine which features would be enabled if you were to change the camera mode from WorldFacingCamera to UserFacingCamera.

    See Also
    Configuration
    ConfigurationChooser
    ConfigurationDescriptor
    Feature

    GetAvailabilityAsync()

    Asynchronously retrieves the SessionAvailability. Used to determine whether the current device supports XR and if the necessary software is installed.

    Declaration
    public Promise<SessionAvailability> GetAvailabilityAsync()
    Returns
    Type Description
    Promise<SessionAvailability>

    A Promise<T> which can be used to determine when the availability has been determined and to retrieve the result.

    Remarks

    This platform-agnostic method is typically implemented by a platform-specific package.

    GetConfigurationDescriptors(Allocator)

    Get the list of supported configuration descriptors. The session can have multiple, discrete modes of operation. A configuration represents the capabilities of a mode of operation, which can be a subset of the session's overal capabilities. That is, the session might support many features, but not all at the same time. This is used by DetermineConfiguration(Feature) to determine the best configuration given a set of requested features.

    Declaration
    public NativeArray<ConfigurationDescriptor> GetConfigurationDescriptors(Allocator allocator)
    Parameters
    Type Name Description
    Unity.Collections.Allocator allocator

    The allocator to use for the returned NativeArray.

    Returns
    Type Description
    Unity.Collections.NativeArray<ConfigurationDescriptor>

    Allocates a new NativeArray and populates it with descriptors describing the supported configurations. The caller owns the memory and is responsible for calling Dispose on the NativeArray.

    InstallAsync()

    Asynchronously attempts to install XR software on the current device. Throws if supportsInstall is false.

    Declaration
    public Promise<SessionInstallationStatus> InstallAsync()
    Returns
    Type Description
    Promise<SessionInstallationStatus>

    A Promise<T> which can be used to determine when the installation completes and to retrieve the result.

    Remarks

    This platform-agnostic method is typically implemented by a platform-specific package.

    OnApplicationPause()

    Should be invoked when the application is paused.

    Declaration
    public void OnApplicationPause()

    OnApplicationResume()

    Should be invoked when the application is resumed.

    Declaration
    public void OnApplicationResume()

    Reset()

    Restarts a session. Stop and Start pause and resume a session, respectively. Restart resets the session state and clears and any detected trackables.

    Declaration
    public void Reset()

    Update(XRSessionUpdateParams)

    Trigger the session's update loop.

    Declaration
    public void Update(XRSessionUpdateParams updateParams)
    Parameters
    Type Name Description
    XRSessionUpdateParams updateParams

    Data needed by the session to perform its update.

    In This Article
    • Constructors
      • XRSessionSubsystem()
    • Properties
      • configurationChooser
      • currentConfiguration
      • currentTrackingMode
      • frameRate
      • matchFrameRateEnabled
      • matchFrameRateRequested
      • nativePtr
      • notTrackingReason
      • requestedFeatures
      • requestedTrackingMode
      • sessionId
      • trackingState
    • Methods
      • DetermineConfiguration(Feature)
      • GetAvailabilityAsync()
      • GetConfigurationDescriptors(Allocator)
      • InstallAsync()
      • OnApplicationPause()
      • OnApplicationResume()
      • Reset()
      • Update(XRSessionUpdateParams)
    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