Gamepad Pressed this Frame#
Input / Gamepad Pressed this Frame
Can Read
Cannot Write
Description#
Returns true the frame the specified Gamepad button is pressed down
Parameters#
| Name | Description |
|---|---|
| Button | The Gamepad button that is checked |
Code#
using System;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.LowLevel;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Get]
[Inline(nameof(m_Button))]
[Title("Gamepad Pressed this Frame")]
[Category("Input/Gamepad Pressed this Frame")]
[Description("Returns true the frame the specified Gamepad button is pressed down")]
[Image(typeof(IconGamepad), ColorTheme.Type.Blue, typeof(BadgeArrowDown))]
[Parameter("Button", "The Gamepad button that is checked")]
[Keywords("Button", "Down", "Just", "Started")]
[Serializable]
public class TypeBoolInputGamepadPressThisFrame : TypeBool
{
[SerializeField] private GamepadButton m_Button = GamepadButton.South;
public override bool Get(Args args)
{
Gamepad gamepad = Gamepad.current;
return gamepad != null && gamepad[this.m_Button].wasPressedThisFrame;
}
public override string ToString()
{
return $"Pressed {this.m_Button}";
}
protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
}
}