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

Touch Count#

Input / Touch Count

  • Can Read

  • Cannot Write

Description#

Returns how many fingers are currently touching the screen

Code#

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

namespace VisualScript.Runtime
{
    [Get]

    [Title("Touch Count")]
    [Category("Input/Touch Count")]

    [Description("Returns how many fingers are currently touching the screen")]
    [Image(typeof(IconTouch), ColorTheme.Type.Blue, typeof(BadgeHash))]

    [Keywords("Screen", "Mobile", "Fingers", "Tap", "Amount")]

    [Serializable]
    public class TypeNumberInputTouchCount : TypeNumber
    {
        public override double Get(Args args)
        {
            Touchscreen touchscreen = Touchscreen.current;
            if (touchscreen == null) return 0d;

            int count = 0;
            foreach (TouchControl touch in touchscreen.touches)
            {
                if (touch.press.isPressed) count += 1;
            }

            return count;
        }

        public override string ToString()
        {
            return "Touch Count";
        }

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