Skip to content

Commit eba5ccb

Browse files
committed
Move to an add-on, add demo project structure
- Display `application/config/version` project setting on the debug menu if present.
1 parent 25bf71a commit eba5ccb

File tree

13 files changed

+250
-59
lines changed

13 files changed

+250
-59
lines changed

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.gd]
12+
indent_style = tab
13+
indent_size = 4

.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# The add-on code in this repository is copied from
2+
# <https://github.com/godot-extended-libraries/godot-debug-menu> regularly.
3+
# Please open pull requests for the add-on code itself there, not in
4+
# this demo repository.
5+
/addons linguist-vendored

.pre-commit-config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.4.0
4+
hooks:
5+
- id: fix-byte-order-marker
6+
- id: end-of-file-fixer
7+
- id: trailing-whitespace
8+
9+
- id: mixed-line-ending
10+
args: [--fix=lf]

README.md

Lines changed: 44 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,47 @@
1-
# Godot Debug Menu
2-
3-
Displays performance information in a Godot project during gameplay. Inspired by
4-
id Tech 6/7's performance overlay.
5-
6-
## Why use this debug menu?
7-
8-
- Compared to the Godot editor's Profiler, Monitors and Visual Profiler bottom
9-
panels, you can look at an in-game debug menu while the project is running,
10-
even in fullscreen if you only have a single monitor.
11-
- Rendering performance is highly dependent on window size, so resizing the
12-
window is not advised for reliable performance measurements in real world
13-
scenarios.
14-
- This debug menu accurately displays graphs and best/worst frametime metrics
15-
over a period of the last 150 rendered frames, which is useful to diagnose
16-
stuttering issues. The Monitor bottom panel is only updated once a second and
17-
doesn't feature a 1% low FPS metric, which makes tracking stuttering
18-
difficult when relying solely on the monitors.
19-
- This debug menu can be used in exported projects to reliably test performance
20-
without any editor interference. This includes testing on mobile and Web
21-
platforms, which tend to be more difficult to set up for profiling within
22-
Godot (if it's even possible).
23-
- This debug menu can be used in exported projects for tech support purposes.
24-
For example, in a bug report, you could ask a player to upload screenshots
25-
with the debug menu visible to troubleshoot performance issues.
26-
27-
External tools such as RTSS or [MangoHud](https://github.com/flightlessmango/MangoHud)
28-
provide some insight on how well a project actually runs. However, they lack
29-
information on engine-specific things such as per-frame CPU/GPU time and
30-
graphics settings.
1+
# Debug Menu add-on demo project for Godot 4.x
2+
3+
**Displays performance information in a Godot project during gameplay.**
4+
Can be used when running from the editor and in exported projects.
5+
Inspired by id Tech 6/7's performance overlay.
6+
7+
![Screenshot](https://raw.githubusercontent.com/Calinou/media/master/godot-debug-menu-demo/screenshot.png)
8+
9+
This repository contains the demo project for the
10+
[Debug Menu add-on](https://github.com/godot-extended-libraries/godot-debug-menu).
11+
The add-on's code is included in this repository and is mirrored periodically.
12+
13+
Please report issues specific to the add-on
14+
[here](https://github.com/godot-extended-libraries/godot-debug-menu), not in this repository.
15+
16+
## Try it out
17+
18+
> **Note**
19+
>
20+
> This add-on only supports Godot 4.x, not Godot 3.x.
21+
22+
### Using the Asset Library
23+
24+
- Open the Godot project manager.
25+
- Navigate to the **Templates** tab and search for "debug menu".
26+
- Install the [*Debug Menu Demo*](https://godotengine.org/asset-library/asset/1903) project.
27+
28+
### Manual installation
29+
30+
Manual installation lets you try pre-release versions of this demo by following its
31+
`master` branch.
32+
33+
- Clone this Git repository:
34+
35+
```bash
36+
git clone https://github.com/godot-extended-libraries/godot-debug-menu-demo.git
37+
```
38+
39+
Alternatively, you can
40+
[download a ZIP archive](https://github.com/godot-extended-libraries/godot-debug-menu-demo/archive/master.zip)
41+
if you do not have Git installed.
42+
43+
- Import the Godot project using the project manager and open it in the editor.
44+
- Run the main scene by pressing <kbd>F5</kbd>.
3145

3246
## License
3347

addons/debug_menu/LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# MIT License
2+
3+
Copyright © 2023-present Hugo Locurcio and contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

debug_menu.gd renamed to addons/debug_menu/debug_menu.gd

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
extends Control
22

3-
43
@export var fps: Label
54
@export var frame_time: Label
65
@export var frame_number: Label
@@ -110,12 +109,19 @@ func _ready() -> void:
110109
update_information_label()
111110
update_settings_label()
112111

113-
func _input(event):
114-
if event.is_action_pressed(&"cycle_debug_menu"):
112+
113+
func _input(event: InputEvent) -> void:
114+
#if event.is_action_pressed(&"cycle_debug_menu"):
115+
if Input.is_key_pressed(KEY_F3):
115116
style = wrapi(style + 1, 0, Style.MAX) as Style
116117

118+
117119
## Update hardware information label (this can change at runtime based on window size and graphics settings).
118120
func update_settings_label() -> void:
121+
settings.text = ""
122+
if ProjectSettings.has_setting("application/config/version"):
123+
settings.text += "Project Version: %s\n" % ProjectSettings.get_setting("application/config/version")
124+
119125
var rendering_method_string := ""
120126
match str(ProjectSettings.get_setting("rendering/renderer/rendering_method")):
121127
"forward_plus":
@@ -124,7 +130,7 @@ func update_settings_label() -> void:
124130
rendering_method_string = "Forward Mobile"
125131
"gl_compatibility":
126132
rendering_method_string = "Compatibility"
127-
settings.text = "Rendering Method: %s\n" % rendering_method_string
133+
settings.text += "Rendering Method: %s\n" % rendering_method_string
128134

129135
var viewport := get_viewport()
130136

debug_menu.tscn renamed to addons/debug_menu/debug_menu.tscn

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
[gd_scene load_steps=3 format=3 uid="uid://bg41amwjmcapd"]
1+
[gd_scene load_steps=3 format=3 uid="uid://cggqb75a8w8r"]
22

3-
[ext_resource type="Script" path="res://debug_menu.gd" id="1_g6ocd"]
3+
[ext_resource type="Script" path="res://addons/debug_menu/debug_menu.gd" id="1_p440y"]
44

55
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ki0n8"]
66
bg_color = Color(0, 0, 0, 0.25098)
@@ -18,7 +18,7 @@ offset_bottom = 408.0
1818
grow_horizontal = 0
1919
size_flags_horizontal = 8
2020
size_flags_vertical = 4
21-
script = ExtResource("1_g6ocd")
21+
script = ExtResource("1_p440y")
2222
fps = NodePath("VBoxContainer/FPS")
2323
frame_time = NodePath("VBoxContainer/FrameTime")
2424
frame_number = NodePath("VBoxContainer/FrameNumber")
@@ -369,7 +369,8 @@ layout_mode = 2
369369
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
370370
theme_override_constants/outline_size = 3
371371
theme_override_font_sizes/font_size = 12
372-
text = "Rendering Method: Forward+
372+
text = "Project Version: 1.2.3
373+
Rendering Method: Forward+
373374
Window: 1234×567, Viewport: 1234×567
374375
3D Scale (FSR 1.0): 100% = 1234×567
375376
3D Antialiasing: TAA + 2× MSAA + FXAA

addons/debug_menu/plugin.cfg

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[plugin]
2+
3+
name="Debug Menu"
4+
description="In-game debug menu displaying performance metrics and hardware information"
5+
author="Calinou"
6+
version="1.0.0"
7+
script="plugin.gd"

addons/debug_menu/plugin.gd

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
@tool
2+
extends EditorPlugin
3+
4+
func _enter_tree() -> void:
5+
add_autoload_singleton("DebugMenu", "res://addons/debug_menu/debug_menu.tscn")
6+
7+
# FIXME: This appears to do nothing.
8+
# if not ProjectSettings.has_setting("application/config/version"):
9+
# ProjectSettings.set_setting("application/config/version", "1.0.0")
10+
#
11+
# ProjectSettings.set_initial_value("application/config/version", "1.0.0")
12+
# ProjectSettings.add_property_info({
13+
# name = "application/config/version",
14+
# type = TYPE_STRING,
15+
# })
16+
#
17+
# if not InputMap.has_action("cycle_debug_menu"):
18+
# InputMap.add_action("cycle_debug_menu")
19+
# var event := InputEventKey.new()
20+
# event.keycode = KEY_F3
21+
# InputMap.action_add_event("cycle_debug_menu", event)
22+
#
23+
# ProjectSettings.save()
24+
25+
26+
func _exit_tree() -> void:
27+
remove_autoload_singleton("DebugMenu")
28+
# Don't remove the project setting's value and input map action,
29+
# as the plugin may be re-enabled in the future.

icon.svg

Lines changed: 50 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)