add some debugging overlays

This commit is contained in:
Chris Cromer 2022-11-20 01:46:03 -03:00
parent 4f32ed03c3
commit f5a7b48f52
3 changed files with 76 additions and 0 deletions

View File

@ -0,0 +1,43 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://scenes/debugger/StateDebugger.cs" type="Script" id=1]
[ext_resource path="res://scenes/debugger/FPS.cs" type="Script" id=2]
[node name="Debugger" type="CanvasLayer"]
[node name="Control" type="Control" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
[node name="VBoxContainer" type="VBoxContainer" parent="Control"]
[node name="HBoxContainer" type="HBoxContainer" parent="Control/VBoxContainer"]
margin_right = 40.0
margin_bottom = 14.0
[node name="Label" type="Label" parent="Control/VBoxContainer/HBoxContainer"]
margin_right = 26.0
margin_bottom = 14.0
text = "FPS:"
[node name="Label2" type="Label" parent="Control/VBoxContainer/HBoxContainer"]
margin_left = 30.0
margin_right = 30.0
margin_bottom = 14.0
script = ExtResource( 2 )
[node name="HBoxContainer2" type="HBoxContainer" parent="Control/VBoxContainer"]
margin_top = 18.0
margin_right = 40.0
margin_bottom = 32.0
[node name="Label" type="Label" parent="Control/VBoxContainer/HBoxContainer2"]
margin_right = 36.0
margin_bottom = 14.0
text = "State:"
[node name="Label2" type="Label" parent="Control/VBoxContainer/HBoxContainer2"]
margin_left = 40.0
margin_right = 40.0
margin_bottom = 14.0
script = ExtResource( 1 )

15
scenes/debugger/FPS.cs Normal file
View File

@ -0,0 +1,15 @@
using Godot;
using System;
public class FPS : Label
{
public override void _Ready()
{
}
public override void _Process(float delta)
{
Text = Engine.GetFramesPerSecond().ToString();
}
}

View File

@ -0,0 +1,18 @@
using Godot;
using System;
public class StateDebugger : Label
{
private Event _event;
public override void _Ready()
{
_event = GetNode<Event>("/root/Event");
_event.Connect("DebugState", this, "OnDebugState");
}
private void OnDebugState(string state)
{
Text = state;
}
}