On Gamepad Release#
Input / Gamepad / On Gamepad Release
Description#
Executes when the Gamepad button is released
Code#
using System;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.LowLevel;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Title("On Gamepad Release")]
[Image(typeof(IconGamepad), ColorTheme.Type.Blue, typeof(BadgeArrowUp))]
[Description("Executes when the Gamepad button is released")]
[Category("Input/Gamepad/On Release")]
[Keywords("Button", "Up")]
[Serializable]
public class TriggerCoreInputGamepadRelease : TriggerHandleSubscriptionBase<HandleOnInputGamepad>
{
// EXPOSED MEMBERS: -----------------------------------------------------------------------
[SerializeField] private GamepadButton m_Button = GamepadButton.South;
// PROPERTIES: ----------------------------------------------------------------------------
protected override string GetTitle(GameObject source)
{
string button = TextUtils.Humanize(this.m_Button);
return $"Release {TextUtils.ThemeAsKeyword(button)}";
}
// OVERRIDE METHODS: ----------------------------------------------------------------------
protected override void OnTrigger(GameObject target)
{
if (!Gamepad.current[this.m_Button].wasReleasedThisFrame) return;
using Args args = Args.Get(this.Component, target);
this.Run(args);
}
}
}