imgui-godot
Godot plugin for integrating Dear ImGui
Still a work in progress, some unfinished stuff, not sure about the interface, probably bugs, resource leaks, etc
Getting Started
When first opening the demo project, you'll get an error about being unable to load the addon script.
Just click Build in the top right corner (if you get errors, you probably need to run nuget restore),
then go into Project > Project Settings > Plugins and re-enable the plugin.
Installing this in your own project is extremely finicky (as of Godot 3.2.3, with C# support in "late alpha"). I've tried to figure out and document the necessary steps.
-
Create a project and click
Buildin the top right to generate the .csproj file. -
Install the plugin by copying over the
addonsfolder. -
Notice that you can't enable the plugin.
-
Well, time to manually edit the .csproj. Refer to the demo csproj for guidance. Add these lines next to the other Compile tags:
<Compile Include="addons\imgui-godot\ImGuiNode.cs" />
<Compile Include="addons\imgui-godot\ImGuiPlugin.cs" />
- While you're here, you can enable unsafe code and add
ImGui.NETas a NuGet package. Or do that in Visual Studio if you prefer.
Add this to all three configurations (probably below ConsolePause):
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Add this with the other PackageReference tags:
<PackageReference Include="ImGui.NET">
<Version>1.75.0</Version>
</PackageReference>
-
Back in Godot, click
Buildagain (if you get errors, you probably need to runnuget restore). -
Enable the plugin in
Project Settings. -
Add an
ImGuiNodeto your scene. -
Write code finally!
Interface
I've provided two ways to use ImGui. See the demo project scenes for examples.
Signals
-
Drop an
ImGuiNodewherever you want in your scene (usually near the end, so it's rendered on top). -
From a script on any other node (or multiple nodes!), connect the
IGLayoutsignal. -
In the function which handles this signal, use
ImGuiNETto create your GUI.
Script extension
If you need to override something, or if you just want to do everything with one node:
-
Add the
ImGuiNode, then useExtend Script. -
The Godot prompt won't let you inherit from
ImGuiNode, so be sure to fix that after your new script is created. -
Override
Layout- seeMyGui.csfor details. Be careful when overriding other methods; it should be ok if you make sure to call the parent method first (usingbase).
Project export
When exporting your project with Godot, the native code cimgui library won't be included. On Windows, you can just copy over cimgui.dll (from .mono\temp\bin\ExportRelease) to the same directory as your exe.
On macOS, I haven't been able to get the .app to work no matter where I put the .dylib. It does work if you run the binary directly.
Credits
All code written by Patrick Dawson, released to the public domain (Creative Commons Zero v1.0 Universal)
Godot Logo (C) Andrea Calabró Distributed under the terms of the Creative Commons Attribution License version 3.0 (CC-BY 3.0) https://creativecommons.org/licenses/by/3.0/legalcode.
Hack font distributed under the MIT license
This plugin's functionality relies heavily on ImGui.NET by Eric Mellino