Class XRManagerSettings | XR Management | 3.0.6
docs.unity3d.com
    Show / Hide Table of Contents

    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 an 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 XRGeneralSettings 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 and properties. Disabling implies the the user is responsible for the full lifecycle of the XR session normally handled by the XRGeneralSettings instance. Toggling this to false also toggles false.

    Disabling 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

    • OnEnable -> 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.
    Inheritance
    Object
    XRManagerSettings
    Namespace: UnityEngine.XR.Management
    Syntax
    public sealed class XRManagerSettings : ScriptableObject

    Properties

    activeLoader

    Return the current singleton active loader instance.

    Declaration
    public XRLoader activeLoader { get; }
    Property Value
    Type Description
    XRLoader

    automaticLoading

    Get and set Automatic Loading state for this manager. When this is true, the manager will automatically call InitializeLoader() and 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.

    Declaration
    public bool automaticLoading { get; set; }
    Property Value
    Type Description
    Boolean

    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.

    Declaration
    public bool automaticRunning { get; set; }
    Property Value
    Type Description
    Boolean

    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.

    Declaration
    public bool isInitializationComplete { get; }
    Property Value
    Type Description
    Boolean

    loaders

    List of loaders currently managed by this XR Manager instance.

    Declaration
    public List<XRLoader> loaders { get; }
    Property Value
    Type Description
    List<XRLoader>

    Methods

    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.

    Declaration
    public T ActiveLoaderAs<T>()
        where T : XRLoader
    Returns
    Type Description
    T

    The active loader as requested type, or null.

    Type Parameters
    Name Description
    T

    Requested type of the loader

    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 tru prior to calling this API.

    Upon return isInitializationComplete will be rest to false;

    Declaration
    public void DeinitializeLoader()

    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.

    Declaration
    public IEnumerator InitializeLoader()
    Returns
    Type Description
    IEnumerator

    Enumerator marking the next spot to continue execution at.

    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.

    Declaration
    public void InitializeLoaderSync()

    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.

    Declaration
    public void StartSubsystems()

    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 tru prior to calling this API.

    Declaration
    public void StopSubsystems()
    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