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
Implements
Inherited Members
Namespace: UnityEngine.XR.ARSubsystems
Assembly: Unity.XR.ARSubsystems.dll
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 |
---|---|
Configuration? |
See Also
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 |
---|---|
int |
Exceptions
Type | Condition |
---|---|
NotSupportedException | Thrown if supportsMatchFrameRate is |
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 |
---|---|
bool |
Exceptions
Type | Condition |
---|---|
NotSupportedException | Thrown if supportsMatchFrameRate is |
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 |
---|---|
bool |
See Also
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
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 |
---|---|
Configuration? | The Configuration the session would use given the requested |
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
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 |
---|---|---|
Allocator | allocator | The allocator to use for the returned NativeArray. |
Returns
Type | Description |
---|---|
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 |
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. |