Skip to content

In‐editor GUI

Patrick Dawson edited this page Apr 30, 2024 · 8 revisions

With the GDExtension installed and the plugin enabled, you can create tool scripts that draw ImGui windows in the editor.

Call ImGuiGD.ToolInit() in your _Ready method, then just draw your GUI as usual in _Process. See sprite_tool.gd for an example.

A tool script's _Process method will only be called when it's attached to a node in the current active scene. After attaching the script to a node, you will need to close and reopen the scene, or save and then reload it with Scene > Reload Saved Scene. But after that, you can change the code and recompile and the results should be instantly visible.

If you want a GUI to be visible regardless of which scene is active, one option is to make an EditorPlugin.

An alternative example:

using Godot;
using ImGuiGodot;
using ImGuiNET;

[Tool]
public partial class AnotherTool : Node
{
    private bool _showImGui = false;

    public override void _Ready()
    {
        if (Engine.IsEditorHint())
            _showImGui = ImGuiGD.ToolInit();
    }

    public override void _Process(double delta)
    {
        if (_showImGui)
        {
            // ImGui stuff
        }

        // do other stuff
    }
}
Clone this wiki locally