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

Seconds since Last Input#

Input / Seconds since Last Input

  • Can Read

  • Cannot Write

Description#

Returns the amount of seconds since any input device was last used

Code#

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

namespace VisualScript.Runtime
{
    [Get]

    [Title("Seconds since Last Input")]
    [Category("Input/Seconds since Last Input")]

    [Description("Returns the amount of seconds since any input device was last used")]
    [Image(typeof(IconTimer), ColorTheme.Type.Blue)]

    [Keywords("Idle", "Away", "Attract", "Inactive", "Time")]

    [Serializable]
    public class TypeNumberInputSecondsSinceLastInput : TypeNumber
    {
        public override double Get(Args args)
        {
            double lastUpdateTime = 0d;

            foreach (InputDevice device in InputSystem.devices)
            {
                if (device.lastUpdateTime > lastUpdateTime) lastUpdateTime = device.lastUpdateTime;
            }

            return Math.Max(0d, InputState.currentTime - lastUpdateTime);
        }

        public override string ToString()
        {
            return "Seconds since last Input";
        }

        protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
    }
}
Visual Script logoVisual Script © Catsoft Works 2026. All rights reserved.