---
tags:
    - "Cursor"
    - "Pointer"
    - "Window"
    - "Bounds"
    - "Outside"
---

# Is Mouse inside Screen

[Input](index.md) / **Is Mouse inside Screen**

<div class="grid cards" markdown>

* :green_circle: Can Read

* :red_circle: Cannot Write

</div>

## Description

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

## Code

```cs
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;
    }
}

```

