Is Input Action Pressed#
Input / Is Input Action Pressed
Can Read
Cannot Write
Description#
Returns true if the specified Input Action value is being held down
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Get]
[Title("Is Input Action Pressed")]
[Category("Input/Is Input Action Pressed")]
[Description("Returns true if the specified Input Action value is being held down")]
[Image(typeof(IconBoltOutline), ColorTheme.Type.Teal)]
[Keywords("Button", "Key", "Down")]
[Serializable]
public class TypeBoolInputActionPress : TypeBool
{
[SerializeField] private InputActionFromAsset m_InputAction = new InputActionFromAsset();
public override bool Get(Args args)
{
UnityEngine.InputSystem.InputAction inputAction = this.m_InputAction.InputAction;
return inputAction?.IsPressed() ?? false;
}
public override string ToString()
{
return $"Pressing {this.m_InputAction}";
}
protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
}
}