On Input Action Perform#
Input / Input Actions / On Input Action Perform
Description#
Executes when an Input Action raises the Performed event
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Title("On Input Action Perform")]
[Image(typeof(IconBoltOutline), ColorTheme.Type.Teal, typeof(BadgeArrowUp))]
[Description("Executes when an Input Action raises the Performed event")]
[Category("Input/Input Actions/On Input Perform")]
[Keywords("System")]
[Serializable]
public class TriggerCoreInputActionPerform : Trigger
{
// EXPOSED MEMBERS: -----------------------------------------------------------------------
[SerializeField] private InputActionFromAsset m_InputAction = new InputActionFromAsset();
// PROPERTIES: ----------------------------------------------------------------------------
protected override string GetTitle(GameObject source) => $"{this.m_InputAction} Perform";
// OVERRIDE METHODS: ----------------------------------------------------------------------
public override void OnEnable()
{
base.OnEnable();
UnityEngine.InputSystem.InputAction inputAction = this.m_InputAction.InputAction;
if (inputAction != null) inputAction.performed += this.OnInputCall;
}
public override void OnDisable()
{
base.OnDisable();
UnityEngine.InputSystem.InputAction inputAction = this.m_InputAction.InputAction;
if (inputAction != null) inputAction.performed -= this.OnInputCall;
}
private void OnInputCall(UnityEngine.InputSystem.InputAction.CallbackContext context)
{
using Args args = Args.Get(this.Component, this.Component);
this.Run(args);
}
}
}