easyDebugMenu

An asset by SoftKitchen
The page banner background of a mountain and forest
easyDebugMenu hero image

Quick Information

0 ratings
easyDebugMenu icon image
SoftKitchen
easyDebugMenu

An easily-extensible generic on-screen in-game debug menu for C#. Provides all benefits of already-available terminal packages, but via GUI, allowing for more user-friendly debugging along with better support for platforms with poor keyboard input, such as consoles and mobile devices.Highly inspired by Unity's EditorGUI class, so Unity developers should easily adjust to this package.

Supported Engine Version
4.0
Version String
1.0.0
License Version
MIT
Support Level
community
Modified Date
4 months ago
Git URL
Issue URL

easyDebugMenu

An easily-extensible generic on-screen in-game debug menu for C#. Highly inspired by Unity's EditorGUI class, so Unity developers should easily adjust to this package.

README Magical Showcase of the Menu

Installation

Godot only supports marking editor plugins as "plugins" unfortunately. For this reason, feel free to simply include the repo files in your project folder directly.

Quick Start

Take a look at the Sample.cs for the full example; this is just a snippet:

using EasyDebugMenu.Components;

class SampleGroup : Group
{
    // Implement the behaviour of your group here
    public override void Draw(VerticalLayout layout)
    {
        // Create a label
        layout.CreateLabel("Sample group");
        
        // Create a horizontal container of multiple elements
        var horizontal = layout.CreateHorizontalLayout();
        
        // Add a button to that container
        horizontal.CreateButton("Button in the layout", () => { GD.Print("Hello World"); });
        
        // Add another button to that container
        horizontal.CreateButton("Another button in the layout", () => { GD.Print("Hello World, again"); });

        // Add an input
        var sampleInput = layout.CreateInput("Sample input", false);
        sampleInput.TextChanged += text => { GD.Print($"Typed... {text}"); };
        
        // Add a secret input
        var secretInput = layout.CreateInput("Secret input", true);
        secretInput.TextChanged += text => { GD.Print($"Typed... {text}"); };
    }
}

class Sample : Node
{
    public override _Ready()
    {
        // Display the menu with one group inside
        DebugMenu.Display(new List<Group>
        {
            new SampleGroup()
        }, this);
    }
}

This is the list of available controls:

Element Description
Vertical Layout Wrapper for Godot.VBoxContainer. Maintains a vertical list of elements. Can spawn other elements.
Horizontal Layout Wrapper for Godot.HBoxContainer. Maintains a horizontal list of elements. Can spawn other elements.
Vertical Split Wrapper for Godot.VSplitContainer. Splits two children controls vertically and adds a size control in between.
Horizontal Split Wrapper for Godot.HSplitContainer. Splits two children controls horizontally and adds a size control in between.
Button Wrapper for Godot.Button. Invokes an "Action" when pressed.
Panel Wrapper for Godot.PanelContainer. Mostly used as a background only.
Label Wrapper for Godot.RichTextLabel. Used to display text.
Input Wrapper for Godot.LineEdit. Used to input data into a text field.

How To

Groups

The idea behind using the EasyDebugMenu is to implement your own so-called Groups and then assign them to the menu which displays them. Each group has three methods that get invoked:

  • Draw(VerticalLayout layout) - Invoked when the group is drawn for the first time. This is used to set up your controls initially and is invoked only once per group.
  • Hide - Invoked when the group is hidden (by showing another group or by hiding it manually). This is used to disable any expensive behaviour your group might be performing. It's not mandatory to be implemented, and you'll probably rarely use this.
  • Show - Invoked when a group is shown, only if it was previously hidden. In context to the Draw method which is invoked only once, this is invoked every time you show a group except for the first time. This is used to update your elements with new states or re-enable any expensive operations you disabled with the Hide. It's not mandatory to be implemented, and you'll probably rarely use this.

Each group will implement the Draw method and use the provided layout to spawn any necessary controls.

Creating Elements

Only the Layout elements are able to spawn other controls. Those controls are appropriately added to the layout which spawned them afterward. You can also implement the IElementCreator interface and handle the spawning on your own or expand it to allow the existing layouts to spawn new controls.

In the project, I mix the term "control" and "element" - in this case, I almost always mean "element". Elements are simple wrappers of already-provided controls in Godot, but wrapped in such a way that they are very ease to use. You can always the IElement interface or the Element abstract class to implement new controls in the future.

To spawn a control, you simply invoke the appropriate method on the layout, like so (following examples implement the overriden Draw method of each control):

public override void Draw(VerticalLayout layout)
{
    // Create a label
    layout.CreateLabel("Sample group label");
}

README Label Sample

You would then go to do this for all other elements you desire, and they would be sorted vertically one after another. You could also sort them horizontally, by using the provided layout to spawn a horizontal layout, and then inside it, spawn your controls:

public override void Draw(VerticalLayout layout)
{
    // Create a label
    layout.CreateLabel("Sample group");
    
    // Create a horizontal container of multiple elements
    var horizontal = layout.CreateHorizontalLayout();
    
    // Add a button to that container
    horizontal.CreateButton("Button in the layout", () => { GD.Print("Hello World"); });
    
    // Add another button to that container
    horizontal.CreateButton("Another button in the layout", () => { GD.Print("Hello World, again"); });
}

README Horizontal Layout Sample

You could even take this a step further and nest layout to create more complex UI, if you really need to. Keep in mind that this is meant to be a package for easy debugging, so I'm not sure how complex you want your UI to be here.

Contributing and Remarks

The current version of the project provides a minimum number of elements you'll most commonly use. I'll add more in the very near future, but feel free to contribute to the repo on your own. You can look at the Label class and it's usages as a good example of how a simple element is structured and created.

You might also notice that elements only have a minimum amount of logic exposed - this is intentional, as it keeps everything simple and encourages using what you have on hand, rather than building complex UI for debugging. If, however, you feel like an element needs more info exposed, feel free to suggest it as well and it will be considered.

An easily-extensible generic on-screen in-game debug menu for C#. Provides all benefits of already-available terminal packages, but via GUI, allowing for more user-friendly debugging along with better support for platforms with poor keyboard input, such as consoles and mobile devices.

Highly inspired by Unity's EditorGUI class, so Unity developers should easily adjust to this package.

Reviews

0 ratings

Your Rating

Headline must be at least 3 characters but not more than 50
Review must be at least 5 characters but not more than 500
Please sign in to add a review

Quick Information

0 ratings
easyDebugMenu icon image
SoftKitchen
easyDebugMenu

An easily-extensible generic on-screen in-game debug menu for C#. Provides all benefits of already-available terminal packages, but via GUI, allowing for more user-friendly debugging along with better support for platforms with poor keyboard input, such as consoles and mobile devices.Highly inspired by Unity's EditorGUI class, so Unity developers should easily adjust to this package.

Supported Engine Version
4.0
Version String
1.0.0
License Version
MIT
Support Level
community
Modified Date
4 months ago
Git URL
Issue URL

Open Source

Released under the AGPLv3 license

Plug and Play

Browse assets directly from Godot

Community Driven

Created by developers for developers