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 mode(s) of operation.
Inheritance
Inherited Members
Namespace: UnityEngine.XR.ARSubsystems
Syntax
public abstract class XRSessionSubsystem : XRSubsystem<XRSessionSubsystemDescriptor>, ISubsystem
Constructors
XRSessionSubsystem()
Do not call this directly. Call create on a valid XRSessionSubsystemDescriptor instead.
Declaration
public XRSessionSubsystem()
Properties
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 |
matchFrameRate
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 matchFrameRate { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Exceptions
Type | Condition |
---|---|
NotSupportedException | Thrown if supportsMatchFrameRate is |
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 |
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
CreateProvider()
Implement this to provide this class with an interface to platform specific implementations.
Declaration
protected abstract XRSessionSubsystem.Provider CreateProvider()
Returns
Type | Description |
---|---|
XRSessionSubsystem.Provider | An implementation specific provider. |
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 retrieve the result. |
Remarks
This platform-agnostic method is typically implemented by a platform-specific package.
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 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()
OnDestroyed()
Destroys the session.
Declaration
protected override sealed void OnDestroyed()
Overrides
OnStart()
Starts or resumes the session.
Declaration
protected override sealed void OnStart()
Overrides
OnStop()
Pauses the session.
Declaration
protected override sealed void OnStop()
Overrides
Reset()
Restarts a session. 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. |