-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_menu.gd
More file actions
36 lines (26 loc) · 872 Bytes
/
debug_menu.gd
File metadata and controls
36 lines (26 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
extends Control
@onready var container: VBoxContainer = $VBoxContainer
var watchers: Dictionary = {}
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
func _process(delta: float) -> void:
for label in watchers.keys():
var data = watchers[label]
var text = data.get("getter").call()
data.get("label_node").text = "%s: %s" % [label, text]
func _input(event: InputEvent) -> void:
if event.is_action_pressed("toggle_debug"):
visible = not visible
get_viewport().set_input_as_handled()
func Register(label: String, getter: Callable) -> void:
if watchers.has(label):
return;
var label_node: Label = Label.new()
label_node.name = label
label_node.text = "%s: ..." % label
container.add_child(label_node)
watchers[label] = {
"getter": getter,
"label_node": label_node
}