docs.unity.cn

OpenXR Plugin 1.14.2

Search Results for

    Show / Hide Table of Contents

    Class OpenXRLayerProvider

    Manages communication of changes between an application and the UnityOpenXR lib for all Unity.XR.CompositionLayers.Layers.LayerData objects.

    Inheritance
    object
    OpenXRLayerProvider
    Implements
    IDisposable
    Namespace: UnityEngine.XR.OpenXR.CompositionLayers
    Assembly: Unity.XR.OpenXR.dll
    Syntax
    public class OpenXRLayerProvider : ILayerProvider, IDisposable
    Remarks

    OpenXR providers or extensions that create custom composition layer types or that override how the built-in layer types are handled, must implement the ILayerProvider interface and register instances of these implementations with the OpenXRLayerProvider via RegisterLayerHandler(Type, ILayerHandler).

    Constructors

    OpenXRLayerProvider()

    Initializes and returns an instance of OpenXRLayerProvider. Initializes and registers all the default, built-in layer handlers.

    Declaration
    public OpenXRLayerProvider()
    Remarks

    The OpenXRLayerProvider is created and disposed by the XRLoader. You do not need to create an instance of OpenXRLayerProvider yourself. Layer handlers should only use the static methods and properties of this class

    Properties

    isStarted

    Reports whether the OpenXRLayerProvider has already been created and started.

    Declaration
    public static bool isStarted { get; set; }
    Property Value
    Type Description
    bool

    Methods

    CleanupState()

    Declaration
    public void CleanupState()

    Dispose()

    Used for cleanup and to call Dispose() on registered layer handlers.

    Declaration
    public void Dispose()
    Remarks

    This is called by the OpenXRLoader class when StopInternal() is invoked.

    LateUpdate()

    Declaration
    public void LateUpdate()

    RegisterLayerHandler(Type, ILayerHandler)

    Registers a concrete OpenXRLayerProvider.ILayerHandler object as the handler for all layers of a specific LayerData subclass.

    Declaration
    public static void RegisterLayerHandler(Type layerDataType, OpenXRLayerProvider.ILayerHandler handler)
    Parameters
    Type Name Description
    Type layerDataType

    The LayerData subclass to handle.

    OpenXRLayerProvider.ILayerHandler handler

    The concrete ILayerHandler instance> to register.

    Remarks

    If more than one object registers itself as a handler for a specific LayerData type, the last registered handler is used.

    The OpenXRLayerProvider invokes the registered layer handler's OpenXRLayerProvider.ILayerHandler methods when any object of the associated LayerData type is updated in some way.

    SetInitialState(List<LayerInfo>)

    Sets the layer provider state on first assignment to the CompositionLayerManager.

    Declaration
    public void SetInitialState(List<CompositionLayerManager.LayerInfo> layers)
    Parameters
    Type Name Description
    List<CompositionLayerManager.LayerInfo> layers

    The list of all currently known CompositionLayer instances, regardless of active state.

    UpdateLayers(List<LayerInfo>, List<int>, List<LayerInfo>, List<LayerInfo>)

    Called by the CompositionLayerManager to tell the instance of ILayerProvider about the current state of layers it is managing.

    Declaration
    public void UpdateLayers(List<CompositionLayerManager.LayerInfo> createdLayers, List<int> removedLayers, List<CompositionLayerManager.LayerInfo> modifiedLayers, List<CompositionLayerManager.LayerInfo> activeLayers)
    Parameters
    Type Name Description
    List<CompositionLayerManager.LayerInfo> createdLayers

    The list of layers that were just created. Any layer in this list may be in the activeLayers list if it is activated in the same frame. Any layer in this list should not be in modifiedLayers or removedLayers. This list is ephemeral and cleared after each call.

    List<int> removedLayers

    The list of layers that are no longer being managed. Any layer in this list should not be in the createdLayers, modifiedLayers, or activeLayers lists. This list is ephemeral and cleared after each call.

    List<CompositionLayerManager.LayerInfo> modifiedLayers

    The list of layers that have been recently modified. Any layer in this list may also be in the activeLayers list. Any layer in this list should not be in createdLayers or removedLayers. This list is ephemeral and cleared after each call.

    List<CompositionLayerManager.LayerInfo> activeLayers

    The list of layers currently active within the scene. Layers in this list may also be in the createdLayers or modifiedLayers lists if they became active in the same frame.

    Events

    Started

    Calls the methods in its invocation list when the OpenXRLayerProvider has started and registered it's built-in layer handlers.

    Declaration
    public static event Action Started
    Event Type
    Type Description
    Action
    Remarks

    You can use this event to wait for the OpenXRLayerProvider to finish registering its built-in layer handlers so that you can override them with your own custom layer handlers.

    Stopped

    Calls the methods in its invocation list when the OpenXRLayerProvider has stopped and is disposed.

    Declaration
    public static event Action Stopped
    Event Type
    Type Description
    Action

    Implements

    IDisposable
    In This Article
    • Constructors
      • OpenXRLayerProvider()
    • Properties
      • isStarted
    • Methods
      • CleanupState()
      • Dispose()
      • LateUpdate()
      • RegisterLayerHandler(Type, ILayerHandler)
      • SetInitialState(List<LayerInfo>)
      • UpdateLayers(List<LayerInfo>, List<int>, List<LayerInfo>, List<LayerInfo>)
    • Events
      • Started
      • Stopped
    • Implements
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)