docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class CompositionLayerUtils

    Collection of utility methods that are useful for CompositionLayer.

    Inheritance
    object
    CompositionLayerUtils
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.XR.CompositionLayers.Services
    Assembly: Unity.XR.CompositionLayers.dll
    Syntax
    public static class CompositionLayerUtils

    Methods

    AddSuggestedExtensions(CompositionLayer)

    Adds the components listed in the SuggestedExtensions from the LayerDataDescriptor corresponding to the layer's GameObject.

    Declaration
    public static void AddSuggestedExtensions(this CompositionLayer layer)
    Parameters
    Type Name Description
    CompositionLayer layer

    The CompositionLayer add the SuggestedExtensions components to.

    CanChangeOrderTo(CompositionLayer, int)

    Checks if the CompositionLayer layer be changed to the order value.

    Declaration
    public static bool CanChangeOrderTo(this CompositionLayer layer, int order)
    Parameters
    Type Name Description
    CompositionLayer layer

    The CompositionLayer to check if can be set to the order value.

    int order

    The value to check if the layer can be set to.

    Returns
    Type Description
    bool

    true if the order can be set the the layer's order value.

    CreateLayerData(string)

    Uses typeFullName to find the LayerData type in the corresponding LayerDataDescriptor. Then creates and returns an instance of the LayerData.

    Declaration
    public static LayerData CreateLayerData(string typeFullName)
    Parameters
    Type Name Description
    string typeFullName

    The type's full name that corresponds to a LayerDataDescriptor that holds the LayerData type information.

    Returns
    Type Description
    LayerData

    If the string typeFullName matches a LayerDataDescriptor an instance of the LayerData type stored in the LayerDataDescriptor is returned. If no matching LayerDataDescriptor is found null is returned.

    CreateLayerData(Type)

    Uses type to find the LayerData type in the corresponding LayerDataDescriptor. Then creates and returns an instance of the LayerData.

    Declaration
    public static LayerData CreateLayerData(Type type)
    Parameters
    Type Name Description
    Type type

    The type of the Layer Data

    Returns
    Type Description
    LayerData

    If the string matches a LayerDataDescriptor an instance of the LayerData type stored in the LayerDataDescriptor is returned. If no matching LayerDataDescriptor is found null is returned.

    GetAllLayerDescriptors()

    Gets a new copy of a list including all known LayerDataDescriptor.

    Declaration
    public static List<LayerDataDescriptor> GetAllLayerDescriptors()
    Returns
    Type Description
    List<LayerDataDescriptor>

    A list of all known LayerDataDescriptor.

    GetLayerDescriptor(string)

    Gets the LayerDataDescriptor that matches typeFullName.

    Declaration
    public static LayerDataDescriptor GetLayerDescriptor(string typeFullName)
    Parameters
    Type Name Description
    string typeFullName

    Id of the corresponding LayerDataDescriptor.

    Returns
    Type Description
    LayerDataDescriptor

    The LayerDataDescriptor that corresponds to the string typeFullName provided. If the string is empty or the LayerDataDescriptor is not found Empty is returned.

    GetLayerDescriptor(Type)

    Gets the LayerDataDescriptor that matches the Type type.

    Declaration
    public static LayerDataDescriptor GetLayerDescriptor(Type type)
    Parameters
    Type Name Description
    Type type

    The Type of the corresponding LayerDataDescriptor.

    Returns
    Type Description
    LayerDataDescriptor

    The LayerDataDescriptor that corresponds to the Type type provided. If the Type is not a subclass of LayerData or the LayerDataDescriptor is not found Empty is returned.

    TryChangeLayerOrder(CompositionLayer, int, int)

    Try to change the layer's order and update the order registered with the CompositionLayerManager from oldOrder to a new order value newOrder.

    Declaration
    public static bool TryChangeLayerOrder(this CompositionLayer layer, int oldOrder, int newOrder)
    Parameters
    Type Name Description
    CompositionLayer layer

    The CompositionLayer to change the order value of.

    int oldOrder

    The old CompositionLayer order value this is usually the current Order.

    int newOrder

    The new CompositionLayer order value to set.

    Returns
    Type Description
    bool

    Returns true if the layer is set to the newOrder or is already set to newOrder.

    TrySwapLayers(CompositionLayer, CompositionLayer)

    Tries to swap the Order values of lhl and rhl.

    Declaration
    public static bool TrySwapLayers(this CompositionLayer lhl, CompositionLayer rhl)
    Parameters
    Type Name Description
    CompositionLayer lhl

    Left hand CompositionLayer to swap the order of.

    CompositionLayer rhl

    Right hand CompositionLayer to swap the order of.

    Returns
    Type Description
    bool

    true if the method was able to swap the lhl and rhl CompositionLayer.

     This can fail if the layers are not in a valid scene, one of the layers is
     the DefaultSceneCompositionLayer, the layers are not tracked by the
     <xref href="Unity.XR.CompositionLayers.Services.CompositionLayerManager" data-throw-if-not-resolved="false"></xref>, or that do not occupy the <xref href="Unity.XR.CompositionLayers.CompositionLayer.Order" data-throw-if-not-resolved="false"></xref> layer
     order with the <xref href="Unity.XR.CompositionLayers.Services.CompositionLayerManager" data-throw-if-not-resolved="false"></xref>.
    
    In This Article
    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)