Skip to content

IL_ScriptableRefs

Eric Lowry edited this page Nov 15, 2024 · 3 revisions

Namespace: namespace Lowry.UI.InputLayers

public sealed class IL_ScriptableRefs : SingletonScriptableObject<IL_ScriptableRefs>

The main ScriptableObject🔗 used as a "singleton" static storage for input layers as a list of priorities.

💡General Information

This class serves three main functions:

  1. Storing user configuration for InputLayers as described here.
  2. Handling the core processes used to assign, sort and validate layers.
  3. Triggering the events that allow other scripts to react to layer changes.

You will need to reference this script whenever you wish to interact directly with the hierarchy of priorities and layers, or have code react to layer activation/deactivation events.

Note: It is built using a SignletonScriptableObject structure; meaning that any property starting with r_ can be accessed directly (ex: IL_ScriptableRefs.r_activeLayer), while any method or a public property without the prefix will need to be called using the Instance reference (ex: IL_ScriptableRefs.Instance.GetLayerByName("Base")).
This also means that only one copy of this script can exist in your project hierarchy. However, its creation is handled automatically; so you should not have to interact with it directly.

ℹ️ As this script is quite extensive, this documentation page only covers properties and methods that are deemed relevant to InputLayers users.*

📄Properties

r_actionsAssets

public static List<InputActionAsset> r_actionsAssets { get {...} set {...} }

The current InputActionAsset file used to define all inputs.

r_priorities

public static List<IL_PriorityLayer> r_priorities { ger {...} }

The main list of IL_Layers split into IL_PriorityLayers (aka. priorities).

r_activeLayer

public IL_Layer r_activeLayer { get {...} }

The currently active layer.
Only one layer can be active at a time.
All others will be "stacked under" it, waiting to be restored when they "resurface" to the top.

r_activePriorityLayer

public static IL_PriorityLayer r_activePriorityLayer { get {...} }

The current priority layer.
It represents the last item in r_priorities with an active layer.

r_actionMaps

public static PseudoSerializableDictionary<InputActionMap, List<LayeredAction>> r_actionMaps { get {...} set {...} }

Holds all s referenced by the InputActionMap they have enabled (see LayeredAction.Enable()).
All maps with actions assigned to them are activated; all others are deactivated.

📄Delegates

r_onActiveLayerChanged

public static Action<IL_Layer> r_onActiveLayerChanged { get {...} set {...} }

Is called when the r_activeLayer is changed.
It will be null if no layer is active.

r_onCurrentPriorityLayerChanged

public static Action<int?> r_onCurrentPriorityLayerChanged { get {...} set {...} }

Is called when the r_activePriorityLayer is changed.
It will be null if no layer is active.

If not null, this int corresponds to an id within the r_priorities list.

📄Methods

AddMap(InputActionMap, LayeredAction)

public void AddMap (InputActionMap map, LayeredAction action) {...}

Adds a map/action reference in .
As long as the LayeredAction remains in the list, the reference map will remain enabled.

Parameters:

  • map: The InputActionMap🔗 to keep enabled while the action is registered.
  • action: The action to register for a given map.

RemoveMap(InputActionMap, LayeredAction)

public void RemoveMap (InputActionMap map, LayeredAction action) {...}

Removes a map/action reference in .
The reference map will only be disabled if this is the last LayeredAction assigned to it.

Parameters:

  • map: The InputActionMap🔗 to no longer keep enabled for the sake of this action.
  • action: The action to unregister for a given map.

GetLayerByName(string)

public IL_Layer GetLayerByName (string name) {...}

Get a layer object based on its name.

Parameters:

  • name: The name of the target layer.

Returns: The unique IL_Layer object which has the provided name.

GetPriority(IL_Layer)

public int? GetPriority (IL_Layer layer_) {...}

Gets a given layer's priority level.

Returns: null if the layer is not included in the r_priorities list.

📄Internal Methods

These are included here to help with overall comprehension of how InputLayers works; but will are not directly useful for your projects.

ActivateLayer(IL_Layer)

internal bool? ActivateLayer (IL_Layer layer_) {...}

Tries to activate a layer.

Note: This method is called when using IL_Layer.Activate().

Parameters:

  • layer_: The layer which should be activated.

Returns:

  • true when the layer has been activated (or was already active).
  • false when the layer has not been activated (it will still be added to the relevant stack).
  • null when the layer isn't present inside any of the r_priorities.

DeactivateLayer(IL_Layer)

internal void DeactivateLayer (IL_Layer layer_) {...}

Deactivates a layer.

Note: This method is called when using IL_Layer.Deactivate().

Parameters:

  • layer_: The layer which should be deactivated.