Skip to content

In‐editor GUI

Patrick Dawson edited this page Aug 28, 2023 · 8 revisions

With the imgui-godot-native plugin installed and 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 MyTool.cs 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. 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 : Control
{
    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