Class XRManagerSettings
Class to handle active loader and subsystem management for XR. This class is to be added as a ScriptableObject asset in your project and should only be referenced by the XRGeneralSettings instance for its use.
Given a list of loaders, it will attempt to load each loader in the given order. The first loader that is successful wins and all remaining loaders are ignored. The loader that succeeds is accessible through the activeLoader property on the manager.
Depending on configuration the XRManagerSettings instance will automatically manage the active loader at correct points in the application lifecycle. The user can override certain points in the active loader lifecycle and manually manage them by toggling the automaticLoading and automaticRunning properties. Disabling automaticLoading implies the the user is responsible for the full lifecycle of the XR session normally handled by the XRManagerSettings instance. Toggling this to false also toggles automaticRunning false.
Disabling automaticRunning only implies that the user is responsible for starting and stopping the activeLoader through the StartSubsystems() and StopSubsystems() APIs.
Automatic lifecycle management is executed as follows
- Runtime Initialize -> InitializeLoader(). The loader list will be iterated over and the first successful loader will be set as the active loader.
- Start -> StartSubsystems(). Ask the active loader to start all subsystems.
- OnDisable -> StopSubsystems(). Ask the active loader to stop all subsystems.
- OnDestroy -> DeinitializeLoader(). Deinitialize and remove the active loader.
Inherited Members
Namespace: UnityEngine.XR.Management
Assembly: solution.dll
Syntax
public sealed class XRManagerSettings : ScriptableObject
Properties
Name | Description |
---|---|
activeLoader | Return the current singleton active loader instance. |
activeLoaders | A shallow copy of the list of loaders currently managed by this XR Manager instance. |
automaticLoading | Get and set Automatic Loading state for this manager. When this is true, the manager will automatically call InitializeLoader() and DeinitializeLoader() for you. When false automaticRunning is also set to false and remains that way. This means that disabling automatic loading disables all automatic behavior for the manager. |
automaticRunning | Get and set automatic running state for this manager. When set to true the manager will call StartSubsystems() and StopSubsystems() APIs at appropriate times. When set to false, or when automaticLoading is false then it is up to the user of the manager to handle that same functionality. |
isInitializationComplete | Read only boolean letting us know if initialization is completed. Because initialization is handled as a Coroutine, people taking advantage of the auto-lifecycle management of XRManager will need to wait for init to complete before checking for an ActiveLoader and calling StartSubsystems. |
loaders | List of loaders currently managed by this XR Manager instance. |
Methods
Name | Description |
---|---|
ActiveLoaderAs<T>() | Return the current active loader, cast to the requested type. Useful shortcut when you need to get the active loader as something less generic than XRLoader. |
DeinitializeLoader() | If there is an active loader, this function will deinitialize it and remove the active loader instance from management. We will automatically call StopSubsystems() prior to deinitialization to make sure that things are cleaned up appropriately. You must wait for isInitializationComplete to be set to true before calling this API. Upon return isInitializationComplete will be rest to false; |
InitializeLoader() | Iterate over the configured list of loaders and attempt to initialize each one. The first one that succeeds is set as the active loader and initialization immediately terminates. When complete isInitializationComplete will be set to true. This will mark that it is safe to call other parts of the API. This does not guarantee that init successfully created a loader. For that you need to check that ActiveLoader is not null. Note that there can only be one active loader. Any attempt to initialize a new active loader with one already set will cause a warning to be logged and immediate exit of this function. Iteration is done asynchronously and this method must be called within the context of a Coroutine. If manual initialization of XR is being done, this method can not be called before Start completes as it depends on graphics initialization within Unity completing. |
InitializeLoaderSync() | Iterate over the configured list of loaders and attempt to initialize each one. The first one that succeeds is set as the active loader and initialization immediately terminates. When complete isInitializationComplete will be set to true. This will mark that it is safe to call other parts of the API. This does not guarantee that init successfully created a loader. For that you need to check that ActiveLoader is not null. Note that there can only be one active loader. Any attempt to initialize a new active loader with one already set will cause a warning to be logged and immediate exit of this function. This method is synchronous and on return all state should be immediately checkable. If manual initialization of XR is being done, this method can not be called before Start completes as it depends on graphics initialization within Unity completing. |
StartSubsystems() | If there is an active loader, this will request the loader to start all the subsystems that it is managing. You must wait for isInitializationComplete to be set to true prior to calling this API. |
StopSubsystems() | If there is an active loader, this will request the loader to stop all the subsystems that it is managing. You must wait for isInitializationComplete to be set to true before calling this API. |
TryAddLoader(XRLoader, int) | Attempts to append the given loader to the list of loaders at the given index. |
TryRemoveLoader(XRLoader) | Attempts to remove the first instance of a given loader from the list of loaders. |
TrySetLoaders(List<XRLoader>) | Attempts to set the given loader list as the list of loaders managed by this instance. |