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

Is Mouse inside Screen#

Input / Is Mouse inside Screen

  • Can Read

  • Cannot Write

Description#

Returns true if the Mouse is within the boundaries of the game window

Code#

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

namespace VisualScript.Runtime
{
    [Get]

    [Title("Is Mouse inside Screen")]
    [Category("Input/Is Mouse inside Screen")]

    [Description("Returns true if the Mouse is within the boundaries of the game window")]
    [Image(typeof(IconFullscreen), ColorTheme.Type.Blue, typeof(BadgeTick))]

    [Keywords("Cursor", "Pointer", "Window", "Bounds", "Outside")]

    [Serializable]
    public class TypeBoolInputMouseInsideScreen : TypeBool
    {
        public override bool Get(Args args)
        {
            Mouse mouse = Mouse.current;
            if (mouse == null) return false;

            Vector2 position = mouse.position.ReadValue();

            return position.x >= 0f && position.x <= UnityEngine.Screen.width &&
                   position.y >= 0f && position.y <= UnityEngine.Screen.height;
        }

        public override string ToString()
        {
            return "Mouse inside Screen";
        }

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