netmasked/scripts/debug_ui.gd

22 lines
478 B
GDScript

extends Control
var lines : Array[String] = []
func _ready() -> void:
EventBus.debug_print.connect(_on_debug_print)
func _process(delta: float) -> void:
$Label.text = "FPS: " + str(Engine.get_frames_per_second()) + "\n"
for l in lines:
$Label.text += l + "\n"
func _on_debug_print(msg : String):
lines.append(msg)
if len(lines) > 10:
lines.pop_front()
func _shortcut_input(event: InputEvent) -> void:
if (event.is_action_pressed("debug")):
visible = !visible