Documentation index for AI agents (llms.txt) A Markdown version of every page is available: request the page's source under /docs/, follow the "alternate" link in this page's head, or start from /llms.txt.
Visual Script logo Manual

While Gamepad Pressing#

Input / Gamepad / While Gamepad Pressing

Description#

Executes every frame that the Gamepad button is being held down

Code#

using System;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.LowLevel;
using VisualScript.Icons;

namespace VisualScript.Runtime
{
    [Title("While Gamepad Pressing")]
    [Image(typeof(IconGamepad), ColorTheme.Type.Blue, typeof(BadgeDot))]
    
    [Description("Executes every frame that the Gamepad button is being held down")]
    [Category("Input/Gamepad/While Pressing")]

    [Keywords("Key", "Hold", "Down")]
    
    [Serializable]
    public class TriggerCoreInputGamepadHold : 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 $"Pressing {TextUtils.ThemeAsKeyword(button)} Down";
        }

        // OVERRIDE METHODS: ----------------------------------------------------------------------
        
        protected override void OnTrigger(GameObject target)
        {
            if (!Gamepad.current[this.m_Button].isPressed) return;
            
            using Args args = Args.Get(this.Component, target);
            this.Run(args);
        }
    }
}
Visual Script logoVisual Script © Catsoft Works 2026. All rights reserved.