netmasked/scripts/debug_ui.gd

22 lines
463 B
GDScript

extends Control
var lines : Array[String] = []
func _ready() -> void:
EventBus.debug_print.connect(_on_debug_print)
EventBus.debug_enable.connect(enable_debug)
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 enable_debug(value : bool):
visible = value