27 lines
883 B
GDScript
27 lines
883 B
GDScript
extends CanvasLayer
|
|
|
|
# Track the current cursor shape
|
|
var current_shape: int = -1
|
|
# References to child nodes (automatically set via $ syntax)
|
|
@onready var texture_rect = $PanelContainer/TextureRect
|
|
@onready var hotspot_marker = $PanelContainer/TextureRect/HotSpotMarker
|
|
|
|
|
|
func _process(_delta):
|
|
# Check the current cursor shape
|
|
var shape = Input.get_current_cursor_shape()
|
|
#Input.set_custom_mouse_cursor()
|
|
if shape != current_shape:
|
|
current_shape = shape
|
|
#update_cursor(shape)
|
|
|
|
|
|
func update_cursor(image: Resource, shape: Input.CursorShape = 0, hotspot: Vector2 = Vector2(0, 0)):
|
|
# Get the custom cursor data from the main script
|
|
if image != null:
|
|
texture_rect.texture = image
|
|
# Position the hotspot marker (assuming a 4x4 marker)
|
|
hotspot_marker.position = hotspot
|
|
else:
|
|
# Clear the texture if no custom cursor is set for this shape
|
|
texture_rect.texture = null
|