Safe export patterns with imgui-godot
masterimgui-godot is disabled. This is useful for ensuring your game remains functional (without the debug UI) in production builds.repository·master·Indexed 21 days ago
https://github.com/pkdawson/imgui-godotA Dear ImGui plugin for Godot 4 that enables rapid UI development for debugging and tools using C#, C++, and GDScript. It provides integration for rendering ImGui windows and widgets within Godot, including support for SubViewports, custom font management via the Fonts class, and thread-safe layout updates using the imgui_layout signal. The plugin can be installed via godotenv, the Godot AssetLib, or built as a custom module from source.
imgui-godot is disabled. This is useful for ensuring your game remains functional (without the debug UI) in production builds.The plugin provides several specialized methods and wrappers:
Image and ImageButton: Simple convenience wrappers for displaying images and buttons.SubViewport: Displays an interactive viewport that receives input events. Requirement: You must set the SubViewport's Update Mode to Always for it to function correctly.All widget calls must occur within _Process or an imgui_layout callback.
To install this example project, you can use the godotenv CLI tool or download it directly from the Godot AssetLib.
Using the CLI:
godotenv addons installTo build the ImGui module as a custom module for Godot, you must first clone the Dear ImGui repository and check out a compatible docking branch, then clone the Godot engine source. Use scons to build Godot while pointing to your custom modules directory.
Prerequisites:
scons installedv1.91.6-docking)imgui-godot module placed in a directory accessible to the custom_modules flag.# 1. Setup Dear ImGui
git clone https://github.com/ocornut/imgui
git -C imgui checkout v1.91.6-docking
# 2. Setup Godot
git clone https://github.com/godotengine/godot
cd godot
# 3. Build Godot with the custom module
scons custom_modules=../modules
# 4. Run the project
cd ../project
godotenv addons install
../godot/bin/godot.* -eIf you are using Godot 4.1 or later with process thread groups, it is strongly recommended to connect to the imgui_layout signal and execute your ImGui code within the handling method rather than _process.
ImGuiGD.Connect(OnImGuiLayout);To install the imgui-godot plugin using the godotenv package manager, run the following command in your terminal:
godotenv addons installAfter running the command, open your Godot project and restart the editor to ensure the plugin is correctly loaded.
To install the plugin in a C# project using the command line, run the following command:
godotenv addons installAlternatively, you can install the plugin directly from the Godot AssetLib.
You can install the plugin using one of the following methods:
csharp-only package from the GitHub Releases.addons folder into your Godot project directory.Project > Project Settings > Plugins and enable the plugin.If you only require C# support without GDExtension, you can use GodotEnv with the following configuration:
{
"addons": {
"imgui-godot": {
"url": "https://github.com/pkdawson/imgui-godot",
"checkout": "6.x",
"subfolder": "addons/imgui-godot"
}
}
}To use ImGui with C#, follow these additional steps after installing the plugin:
Project > Tools > C# > Create C# solution).ImGui.NET NuGet package.ImGui.NET version that matches the version the GDExtension was built with.Project > Project Settings > Plugins..csproj and Globals.cs files in the example project to see the recommended configuration changes for conditional compilation or feature toggling.To build the GDExt example and set up its environment, run the following commands in sequence:
scons.project directory.godotenv addons install to install the necessary addons for the project.scons
cd project
godotenv addons installImGuiConfig resource. Then, navigate to Project > Project Settings > Addons > Imgui and assign your resource to the Config property.