pkdawson/imgui-godot

Godot Editor crashes with ImGui under [Tool] nodes

Closed this issue · 3 comments

runs "in game" fine.

When creating a simple project with this as the script for the loading scene, it crashes.

using Godot;
using System;
using ImGuiNET;

[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();
	}
}

Crashes on the first line with

System.AccessViolationException
  HResult=0x80004003
  Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
  Source=<Cannot evaluate the exception source>
  StackTrace:
<Cannot evaluate the exception stack trace>

image

Crashes the editor upon startup until rebuilding the csharp code with the ImGui lines commented out.

Ideally I would be able to use ImGui in the editor via [Tool] nodes, just like in-game.

specs:

  • Win11
  • Godot 4.3.stable.mono
  • ImGui v1.91.0.1 via Nuget
  • ImGui-Godot as of today (via repo)

I see in #58 the use of ToolInit(). I tried adding that:

	private bool isImGuiInit = false;
	public override void _Ready()
	{
		base._Ready();
		isImGuiInit = ImGuiGD.ToolInit();
	}

but it always returns false (including when I try recalling it from _Process()). This always returns false both in the editor and when running in debug.

I got it "working" (not crashing).... I used the addon folder from the git repo, not the releases. switching to releases now works.

image

Yes, using ImGui in the editor is one feature that absolutely requires the GDExtension.

https://github.com/pkdawson/imgui-godot/wiki/In%E2%80%90editor-GUI