Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docs on [Tool] use. #83

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,47 @@ to install and update imgui-godot. The configuration should be something like:
}
```

## [Tool] use (ImGui in the Godot Editor)

Lets start with a simple example:

```csharp
[Tool]
public partial class Hello : Node3D
{
public override void _Process(double delta)
{
ImGui.Begin("ImGui on Godot 4");
ImGui.Text("hello world Test");
ImGui.End();
}
}
```

To use ImGui from within the Godot Editor, you must do the following:

1. Install the full GDExtension version of ImGui-Godot
2. call ImGuiGD.ToolInit() first.

Failure to do these will cause the godot editor to hard crash when running the above example. Comment out the `ImGui.` lines and rebuild to prevent future crashes.

An easy way to ensure `ImGuiGD.ToolInit()` is always called is to use a `[ModuleInitializer]`, as shown:

```csharp
internal static class ImGuiInit
{
[ModuleInitializer]
public static void DoInit()
{
ImGuiGD.ToolInit();
}
}
```

If you do this and still don't see the "hello world Test" text, keep in mind that ImGui will be rendered somewhere in the Godot Editor window, not constrained to the Camera viewport. It might be hiding in plain sight, like this image shows:
![image](https://github.com/user-attachments/assets/b64375b4-a89a-4eb6-92b9-2c528651930b)


## Credits

Code written by Patrick Dawson and contributors, released under the MIT license
Expand Down