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