FPS counter

godot-4.3
John Montagu, the 4th Earl of Sandvich 2024-01-02 17:04:12 -08:00
parent e2781c81f2
commit 4b0b0aab09
Signed by: sandvich
GPG Key ID: 9A39BE37E602B22D
2 changed files with 30 additions and 1 deletions

View File

@ -1,8 +1,9 @@
[gd_scene load_steps=4 format=3 uid="uid://be8bc4eivsg4s"] [gd_scene load_steps=5 format=3 uid="uid://be8bc4eivsg4s"]
[ext_resource type="Script" path="res://Debug/DebugConsole.cs" id="1_3fw5a"] [ext_resource type="Script" path="res://Debug/DebugConsole.cs" id="1_3fw5a"]
[ext_resource type="Script" path="res://UI/Debug/DebugUI.cs" id="1_b7eq2"] [ext_resource type="Script" path="res://UI/Debug/DebugUI.cs" id="1_b7eq2"]
[ext_resource type="Script" path="res://Debug/Entry.cs" id="2_kdlsh"] [ext_resource type="Script" path="res://Debug/Entry.cs" id="2_kdlsh"]
[ext_resource type="Script" path="res://UI/Debug/FramerateCounter.cs" id="4_e5jgp"]
[node name="DebugUI" type="CanvasLayer"] [node name="DebugUI" type="CanvasLayer"]
process_mode = 3 process_mode = 3
@ -56,3 +57,19 @@ code_completion_enabled = true
auto_brace_completion_enabled = true auto_brace_completion_enabled = true
auto_brace_completion_highlight_matching = true auto_brace_completion_highlight_matching = true
script = ExtResource("2_kdlsh") script = ExtResource("2_kdlsh")
[node name="Control" type="ColorRect" parent="."]
anchors_preset = 1
anchor_left = 1.0
anchor_right = 1.0
grow_horizontal = 0
color = Color(0, 0, 0, 0.501961)
[node name="Label" type="Label" parent="Control"]
layout_direction = 3
layout_mode = 2
offset_right = 41.0
offset_bottom = 23.0
text = "0 FPS"
horizontal_alignment = 2
script = ExtResource("4_e5jgp")

View File

@ -0,0 +1,12 @@
using System;
using Godot;
namespace SupaLidlGame.UI;
public partial class FramerateCounter : Label
{
public override void _Process(double delta)
{
Text = $"{Math.Round(Engine.GetFramesPerSecond())} FPS";
}
}