Class CompositionLayerManager
Singleton manger for defined composition layers and updating layer information for a given ILayerProvider instance.
The expected lifecycle of a layer in relation to the manager is as follows: | Composition Layer | Manager | Reported State | | -- | -- | -- | | Awake | CompositionLayerCreated(CompositionLayer) | Created | | OnEnable | CompositionLayerEnabled(CompositionLayer) | Modified, Active | | OnDisable | CompositionLayerDisabled(CompositionLayer) | Modified | | OnDestroy | CompositionLayerDestroyed(CompositionLayer) | Removed |
The manager will report the set of created, removed, modified and active layers to the s_LayerProvider instance on every Update call. These lists are defined to contain layers a follows:
Created : Any layer that has just been created. Populated on calls to CompositionLayerCreated(CompositionLayer).
This list is ephemeral and is cleared after each call to the layer provider.
Removed : Any layer that has been destroyed will cause a call to CompositionLayerDestroyed(CompositionLayer). The layer will be removed from the created, active and modified lists and added to the removed list.
This list is ephemeral and is cleared after each call to the layer provider.
Modified : Any layer that has changed in some way be added to this list. A modification could be a property change, or the layer being re-activated or de-activated. A layer is only added to this list if it isn't already in the Created or Removed lists.
This list is ephemeral and is cleared after each call to the layer provider.
A layer will only exist in one of Removed, Created or Modified on any call to the s_LayerProvider.
Active : This list contains the current set of active layers for this update call to the s_LayerProvider. Layers passed to CompositionLayerEnabled(CompositionLayer) will be added to this list, and layers passed to CompositionLayerDisabled(CompositionLayer) or CompositionLayerDestroyed(CompositionLayer) will be removed from this list.
Inherited Members
Namespace: Unity.XR.CompositionLayers.Services
Assembly: solution.dll
Syntax
public sealed class CompositionLayerManager
Properties
DefaultSceneCompositionLayer
The CompositionLayer that is being used to render the default scene layer in a composition.
Declaration
public CompositionLayer DefaultSceneCompositionLayer { get; }
Property Value
Type | Description |
---|---|
CompositionLayer |
EmulationLayerProvider
The currently assigned ILayerProvider emulation provider instance that this manager instance should talk to.
Declaration
public ILayerProvider EmulationLayerProvider { get; set; }
Property Value
Type | Description |
---|---|
ILayerProvider |
Instance
Singleton instance of CompositionLayerManager.
Declaration
public static CompositionLayerManager Instance { get; }
Property Value
Type | Description |
---|---|
CompositionLayerManager | Singleton instance of the CompositionLayerManager |
LayerProvider
The currently assigned ILayerProvider instance that this manager instance should talk to.
Declaration
public ILayerProvider LayerProvider { get; set; }
Property Value
Type | Description |
---|---|
ILayerProvider |
Methods
CompositionLayerCreated(CompositionLayer)
Called to report that a new instance of a CompositionLayer is created. By default this is called from calls to Awake on a CompositionLayer instance.
Declaration
public void CompositionLayerCreated(CompositionLayer layer)
Parameters
Type | Name | Description |
---|---|---|
CompositionLayer | layer | New layer to add to management. |
CompositionLayerDestroyed(CompositionLayer)
Called to report that an instance of a CompositionLayer is being destroyed and or should be removed from management. By default this is called from calls to OnDestroy on a CompositionLayer instance.
When called the layer will be added to the removed layer list. If layer is currently active, the layer will be removed from the active list as well.
If the manager doesn't know about this layer (i.e. the layer instance was not passed to CompositionLayerCreated(CompositionLayer) previously) then the layer is ignored.
Declaration
public void CompositionLayerDestroyed(CompositionLayer layer)
Parameters
Type | Name | Description |
---|---|---|
CompositionLayer | layer | Currently managed layer to remove from management. |
CompositionLayerDisabled(CompositionLayer)
Called to report that an instance of a CompositionLayer is not active and should not be rendered. By default this is called from calls to OnDisable on a CompositionLayer instance.
When called with a layer that is active, the layer will be removed from the active list.
If the manager doesn't know about this layer (i.e. the layer instance was not passed to CompositionLayerCreated(CompositionLayer) previously) then the layer is ignored.
Declaration
public void CompositionLayerDisabled(CompositionLayer layer)
Parameters
Type | Name | Description |
---|---|---|
CompositionLayer | layer | Currently managed layer to set to disabled. |
CompositionLayerEnabled(CompositionLayer)
Called to report that an instance of a CompositionLayer is active and ready to be rendered. By default this is called from calls to OnEnable on a CompositionLayer instance.
When called with a layer that is not currently active, the layer will be added to the active list as well as the added list.
If the manager doesn't know about this layer (i.e. the layer instance was not passed to CompositionLayerCreated(CompositionLayer) previously) then the layer is ignored.
Declaration
public void CompositionLayerEnabled(CompositionLayer layer)
Parameters
Type | Name | Description |
---|---|---|
CompositionLayer | layer | Currently managed layer to set to active. |
CompositionLayerStateChanged(CompositionLayer)
Report a change in state/data for a layer. This could be direct layer state changes or it could be due to changes in data on extension components for this layer.
Declaration
public void CompositionLayerStateChanged(CompositionLayer layer)
Parameters
Type | Name | Description |
---|---|---|
CompositionLayer | layer | The CompositionLayer that is modified. |
GetFirstUnusedLayer()
Get the first unoccupied layer Order value that is greater than 0 in the currently open scenes.
Declaration
public static int GetFirstUnusedLayer()
Returns
Type | Description |
---|---|
int | Returns the first unoccupied order value order value. |
GetFirstUnusedLayer(bool)
Get the first unoccupied Order value in the currently open scenes.
Declaration
public static int GetFirstUnusedLayer(bool overlay)
Parameters
Type | Name | Description |
---|---|---|
bool | overlay | If the first unoccupied order value greater than 0 is returned. If the first
unoccupied order value less than 0 is returned.
|
Returns
Type | Description |
---|---|
int | Returns the first unoccupied order value order value. |
GetNextUnusedLayer(int)
Gets the next unoccupied layer Order value that is greater than order
if the value is positive or less than if the value is negative.
Declaration
public static int GetNextUnusedLayer(int order)
Parameters
Type | Name | Description |
---|---|---|
int | order | The order value to get the next unoccupied value for. |
Returns
Type | Description |
---|---|
int | The next unoccupied layer Order value that is greater than |
GetNextUnusedLayer(int, bool)
Gets the next unoccupied layer Order value that is greater than or less than
order
.
Declaration
public static int GetNextUnusedLayer(int order, bool overlay)
Parameters
Type | Name | Description |
---|---|---|
int | order | The order value to get the next unoccupied value for. |
bool | overlay | If the first unoccupied order value greater than order is returned.
If the first unoccupied order value less than order is returned.
|
Returns
Type | Description |
---|---|
int | The next unoccupied layer Order value that is greater than |
ResetDefaultSceneCompositionLayer()
Reset the DefaultSceneCompositionLayer back to the fallback CompositionLayer provided byt the CompositionLayerManager.
Declaration
public void ResetDefaultSceneCompositionLayer()
SetDefaultSceneCompositionLayer(CompositionLayer)
Sets the CompositionLayer to be used as the DefaultSceneCompositionLayer. This will unset and disable the previous DefaultSceneCompositionLayer. If the DefaultSceneCompositionLayer fails to be set to the CompositionLayer a fallback will be used.
Declaration
public void SetDefaultSceneCompositionLayer(CompositionLayer compositionLayer)
Parameters
Type | Name | Description |
---|---|---|
CompositionLayer | compositionLayer | The layer to use as the DefaultSceneCompositionLayer. |