Pointer Position#
Input / Pointer Position
Can Read
Cannot Write
Description#
Returns current position of the Mouse, Pen or Touch pointer
Code#
using System;
using UnityEngine;
using UnityEngine.InputSystem;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Get]
[Title("Pointer Position")]
[Category("Input/Pointer Position")]
[Description("Returns current position of the Mouse, Pen or Touch pointer")]
[Image(typeof(IconCursor), ColorTheme.Type.Blue, typeof(BadgePosition))]
[Keywords("Cursor", "Mouse", "Touch", "Pen", "Screen", "Point")]
[Serializable]
public class TypeVector2InputPointerPosition : TypeVector2
{
public override Vector2 Get(Args args)
{
Pointer pointer = Pointer.current;
return pointer != null ? pointer.position.ReadValue() : default;
}
public override string ToString()
{
return "Pointer Position";
}
protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
}
}