Skip to content

IL_LayeredAction

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

Namespace: namespace Lowry.UI.InputLayers

public sealed class IL_LayeredAction : MonoBehaviour

For use in the Inspector only.
Allows the use of LayeredActions in the Unity inspector.

💡General Information

This script is designed to expose a LayeredAction in the Unity Inspector.

It lets you assign a Unity InputAction🔗 to a specific IL_Layer, and then control both the layer and InputAction through configuring its fields in the inspector and by calling its public methods.

Along with the IL_LayerToggle script, it lets you make full use of InputLayers directly from within the Unity Editor interface.

📄Fields

_layeredAction

private LayeredAction _layeredAction;

Defines the InputAction🔗 that will trigger the _onEventTriggered IF the correct IL_Layer is active.

_eventTypeUsed

private ActionEventType _eventTypeUsed = ActionEventType.performed;

Determines whether _onEventTriggered will trigger when the _layeredAction's onStartedEvent, onPerformedEvent or onCanceledEvent is called.

_onEventTriggered

private UnityEvent _onEventTriggered;

Will be triggered when _layeredAction's event corresponding to the value of _eventTypeUsed is called IF its corresponding IL_Layer is active.

_enableOnStart

private bool _enableOnStart = true;

If true, _layeredAction will be enabled when the object is loaded.

_enableActionMapOnStart

private bool _enableActionMapOnStart = true;

If true, _layeredAction's InputActionMap🔗 will be enabled when the object is loaded.

_enableInputActionOnStart

private bool _enableInputActionOnStart = true;

If true, _layeredAction._action (InputAction🔗) will be enabled when the object is loaded.

_disableOnDestroy

private bool _disableOnDestroy = true;

If true, _layeredAction will be disabled when the object destroyed.

_disableActionMapOnDestroy

private bool _disableActionMapOnDestroy = false;

If true, _layeredAction._action (InputAction🔗) will be disabled when the object is destroyed.

_disableInputActionOnDestroy

private bool _disableInputActionOnDestroy = false;

If true, _layeredAction._action (InputAction🔗) will be disabled when the object is destroyed.

_activateLayerOnStart

private bool _activateLayerOnStart = true;

If true, _layeredAction._layer (InputLayer) will be enabled when the object is loaded.

_deactivateLayerOnDestroy

private bool _deactivateLayerOnDestroy = true;

If true, _layeredAction._layer (InputLayer) will be disabled when the object is destroyed.

📄Methods

Enable()

public void Enable ()

Calls EnableWithParameters() with default values of enableActionMap = true and enableInputAction = true.

EnableWithParameters(bool, bool)

public void EnableWithParameters (bool enableActionMap, bool enableInputAction)

Enables this script's and registers the appropriate event based on .

Parameters:

  • enableActionMap: If true, the InputActionMap🔗 this action belongs to will be enabled.
    The map will remain enabled as long as LayeredActions that belong to it are enabled.
  • enableInputAction: If true, the action will be "manually" enabled.

Disable()

public void Disable ()

Calls EnableWithParameters() with default values of disableActionMap = false and disableInputAction = false.

DisableWithParameters(bool, bool)

public void DisableWithParameters (bool disableActionMap, bool disableInputAction)

Disables this script's and unregisters the appropriate event based on .

Parameters:

  • disableActionMap: If true, the InputActionMap🔗 this action belongs to will be disabled.
    The map will remain enabled as long as LayeredActions that belong to it are enabled.
  • disableInputAction: If true, the action will be "manually" disabled.

DisableActionMap()

public void DisableActionMap ()

Disables the InputActionMap🔗 this action belongs to.

ActivateLayer()

public void ActivateLayer ()

Activates the IL_Layer that _layeredAction._action belongs to.

DeactivateLayer()

public void DeactivateLayer ()

Deactivates the IL_Layer that _layeredAction._action belongs to.

OnStartedEvent(CallbackContext)

private void OnStartedEvent (CallbackContext context)

Triggered when _layeredAction is triggered IF _eventTypeUsed has a value of ActionEventType.started.

OnPerformedEvent(CallbackContext)

private void OnPerformedEvent (CallbackContext context)

Triggered when _layeredAction is triggered IF _eventTypeUsed has a value of ActionEventType.performed.

OnCanceledEvent(CallbackContext)

private void OnCanceledEvent (CallbackContext context)

Triggered when _layeredAction is triggered IF _eventTypeUsed has a value of ActionEventType.canceled.

📄Enums

ActionEventType

public enum ActionEventType
{
	started,
	performed,
	canceled
}

Used to select the type of LayeredAction delegates this script should call the _onEventTriggered UnityEvent for in the inspector.

Clone this wiki locally