godot如何实现UI控件/窗口的拖动

Viewed 23

1.给控件添加对应脚本
2.链接signal信号_on_gui_input
3.给_on_gui_input方法添加拖动代码

var clicked = false
func _on_gui_input(event):
	clicked = Input.is_action_pressed("left_click")
	if event is InputEventMouseMotion and clicked:
		position +=event.relative

实现非常简单

0 Answers