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.
Namespace: UnityEngine.XR.ARSubsystems
Syntax
public abstract class XRSessionSubsystem : Subsystem<XRSessionSubsystemDescriptor>
Constructors
XRSessionSubsystem()
Do not call this directly. Call create on a valid XRSessionSubsystemDescriptor instead.
Declaration
public XRSessionSubsystem()
Fields
m_Running
Implementing classes must set this value to reflect the running state of the subsystem
Declaration
protected bool m_Running
Field Value
Type | Description |
---|---|
Boolean |
Properties
frameRate
The native update rate of the AR Session.
Declaration
public int frameRate { get; }
Property Value
Type | Description |
---|---|
Int32 |
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 |
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 |
running
Whether the session is currently running.
Declaration
public bool running { get; }
Property Value
Type | Description |
---|---|
Boolean |
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.IProvider CreateProvider()
Returns
Type | Description |
---|---|
XRSessionSubsystem.IProvider | An implementation specific provider. |
Destroy()
Destroys the session.
Declaration
public sealed override void Destroy()
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()
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()
Start()
Starts or resumes the session.
Declaration
public override void Start()
Stop()
Pauses the session.
Declaration
public override void Stop()
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. |