Closed c-schembri closed 2 months ago
Right, the plugin's autoload singleton isn't loaded by the editor, so ImGui isn't initialized. I'll see if I can find a good way to make that an option.
I'm having a problem where an in-editor ImGui window won't respond to input - unless I add a GD.Print()
call every frame, then it works fine. Very confusing. I'll try to figure it out.
Oh ok, it's just the editor trying to avoid constantly redrawing itself. It works if I turn on Update Continuously
. I'll either document that or find a workaround.
The main difficulty here is that imgui-godot is part of the main project assembly, so whenever you compile, everything needs to be cleanly reloaded. I can get that mostly working, but it's buggy enough that it's not really usable. And I suspect that even if I can fix all the bugs, future Godot releases will be likely to break it.
The solution would be to move imgui-godot to its own GDExtension, which I was planning to do whenever C# GDExtension support is available. I could also make a C++ GDExtension, which has a number of other advantages.
I guess we can just leave this issue open for now. Whether you want to add support for this feature or not is completely up to you, of course. This request is not a super important one (if really needed one can just make an ImGui standalone executable). But I appreciate you looking into this and updating the issue constantly. It's not everyday you get to find OSS that has a reliable owner! So thank you!
I'm always happy to see people actually using my addon, so I like getting feature requests.
I've been working on the C++ GDExtension, I expect to have a beta ready in 3-4 weeks. Running in-editor is still a little tricky, but far more stable than trying to do it in pure C#.
Appreciate it. If I ever get around to releasing my game (a tall order, as every game developer knows), I will definitely credit you for this work.
Sorry for the delay, it took me forever to get around to writing even basic docs.
I still have some work to do on other features, but the in-editor GUI stuff should be stable.
If you feel like trying out the beta, I'd very much welcome any feedback about usability, bug reports, or questions.
https://github.com/pkdawson/imgui-godot/releases/tag/v5.0.0-beta1
https://github.com/pkdawson/imgui-godot/wiki/In%E2%80%90editor-GUI
No problem. Thanks for the work you've put into this! I greatly appreciate it.
It seems that this release required your project to be using Godot 4.1, is that correct? I'm still using 4.0.3 so I have to update my project when I work on it next. Afterwards, I'll give the new release a go and let you know if I notice any issues or bugs or have any questions.
Again, thank you for your work on this.
Yeah there's a new GDExtension API in Godot 4.1, so that's the minimum version.
I've been trying to change the font of the ImGui interface but nothing seems to be working. I've tried the ImGuiGD.AddFont method as well as the method in the README with the ImGuiConfig.tres configuration--but neither are working. Any advice?
To configure the native plugin, you can set the config resource on the ImGuiGodot
node in res://addons/imgui-godot-native/ImGuiGodot.tscn
. I need to document that.
I originally intended to have it use the configuration from the C# node as a fallback, but there were some technical complications. I'll see if I can figure out how to get that working.
The ImGuiGD.AddFont
stuff should work. It's the same as before: ResetFonts, then AddFont, then RebuildFontAtlas (in an _EnterTree or _Ready method).
Admittedly not the nicest API, but I figured not many people would want to use it anyway.
Thanks for that information. I got the fonts working through the ImGuiGD class. One major issue I am experiencing is that when I rebuild the [Tool] which uses ImGui code, I often get the error found at https://github.com/godotengine/godot/issues/78513. This error forces me to re-open the project entirely, making it very slow to get any work done.
I don't know if you can do anything about it, because it seems like an issue outside of this domain. But I just wanted to report my experience.
Here's the actual error reported by the Godot Editor:
modules/mono/mono_gd/gd_mono.cpp:513 - .NET: Failed to unload assemblies. Please check https://github.com/godotengine/godot/issues/78513 for more information. (User)
modules/mono/mono_gd/gd_mono.cpp:513 - .NET: Failed to unload assemblies. Please check https://github.com/godotengine/godot/issues/78513 for more information. (User)
modules/mono/mono_gd/gd_mono.cpp:513 - .NET: Failed to unload assemblies. Please check https://github.com/godotengine/godot/issues/78513 for more information. (User)
modules/mono/mono_gd/gd_mono.cpp:497 - .NET: Giving up on assembly reloading. Please restart the editor if unloading was failing. (User)
At the same time, all [Tool] scripts are disabled until the editor is restarted.
That sounds like it's probably a problem with my code. But I can't reproduce it on Windows 11 or macOS 14, with .NET 7.
Which OS and .NET SDK are you using?
Can you reproduce it with the demo project (included in the .zip with the native binaries)? Open the project, enable the native plugin, restart the editor, then try to change MyTool.cs and rebuild.
After some testing I don't believe it's this library's fault that I am running into the above issue. I believe it's other libraries. I could not reproduce the issue using a barebones solution with just this library.
Guys, I made some changes to get ImGui running in the editor. If you are interested in my modifications, please let me know.
@lihaochen910 Sure, I'd love to hear any details, or see the code if you want to share it.
I'm still working on a rewrite of the native GDExtension, which would support an in-editor GUI. I've had very little time in the past couple months, but I should get back to it soon.
@pkdawson Regarding this feature, I have opened a Pull Request. Tested in Godot version 4.2.1.
Implemented in v5.0.0
Currently, if you run any ImGuiNET code in the editor Godot will crash, and you will have to delete the offending code and rebuild to stop the crashing.
I'm not 100% sure if the issue is with this plugin or ImGuiNET generally, but I thought it was worth bringing to this project's attention.
Minimal example (and attach to a Node in the scene):