-
-
Notifications
You must be signed in to change notification settings - Fork 0
LayeredAction
Namespace: namespace Lowry.UI.InputLayers
public class LayeredAction
Used to represent an IL_Action and register its InputAction🔗, but filtered to only fire when the desired InputLayer (_layer) is active.
This class is used as a filtering system for Unity's InputAction🔗 within the context of InputLayers.
The core concept is that events raised by the InputAction🔗 will only be passed onto this script's delegates if the _layer it is registered under is active.
This class is designed to be exposed as a serialized field🔗 within your own scripts in order to expose its custom property drawer in your Unity Inspector.
This allows you to easily select a specific InputAction🔗 and the InputLayer it should be registered to.
Then, you can simply react to its delegates in order to perform the desired actions.
Tip: In cases where another type of input should trigger the same effect as this LayeredAction (such as clicking on a button instead of using a controller input to activate it), then you can filter it based on _layer._isActive, or use the _layer.onActivated and _layer.onDeactivated events to know if the action's layer is currently active.
private IL_Action _action;
Used to represent the InputAction🔗 this acts as a filtered pass-through for.
public InputLayer _layer;
The InputLayer that must be active for these actions to be performed.
public InputAction _inputAction { get {...} }
The InputAction🔗 this acts as a filtered pass-through for.
public string _name { get {...} }
The name of the InputAction🔗 this acts as a filtered pass-through for.
public InputActionType _type { get {...} }
The InputActionType🔗 of the InputAction🔗 this acts as a filtered pass-through for.
public event Action<CallbackContext> onPerformedEvent;
public event Action<CallbackContext> onStartedEvent;
public event Action<CallbackContext> onCanceledEvent;
public void Enable (bool enableMap = false, bool enableAction = false) {...}
Initializes this action, enabling it and/or the entire map it belongs to.
The map will remain enabled as long as s that belong to it are enabled.Parameters:
- enableMap: 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.- enableAction: If
true
, the action will be "manually" enabled.
public void Disable (bool disableMap = false, bool disableAction = false) {...}
Closes down this action, disabling it and/or the entire map it belongs to.
The map will remain enabled as long as LayeredActions that belong to it are enabled.Parameters:
- disableMap: 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.- disableAction: If
true
, the action will be "manually" disabled.
public void EnableMap () {...}
Enables the InputActionMap🔗 this action belongs to.
public void DisableMap () {...}
Tires to disable the InputActionMap🔗 this action belongs to.
public virtual void ActionPerformed (InputAction.CallbackContext context) {...}
Must be called as a result of _action being Performed.
public virtual void PerformAction(InputAction.CallbackContext? context) {...}
Can be called to force the onPerformedEvent to be triggered as long as _layer is active.
Parameters:
- context: Should be left as
null
when using this method manually.
public virtual void ActionStarted (InputAction.CallbackContext context) {...}
Must be called as a result of _action being Started.
public virtual void StartAction(InputAction.CallbackContext? context) {...}
Can be called to force the onStartedEvent to be triggered as long as _layer is active.
Parameters:
- context: Should be left as
null
when using this method manually.
public virtual void ActionCanceled (InputAction.CallbackContext context) {...}
Must be called as a result of _action being Canceled.
public virtual void CancelAction(InputAction.CallbackContext? context) {...}
Can be called to force the onCanceledEvent to be triggered as long as _layer is active.
Parameters:
- context: Should be left as
null
when using this method manually.
👉🏻 Download InputLayers on the Unity Asset Store!