Android build (non-desktop) breaks addon
Closed this issue · 4 comments
Android build breaks addon completely.
From what I understand there's no way to use platform-specific code either.
I have even added code to check for OS and/or feature flags to no avail. Still breaks.
What can be done to fix this?
Godot Version
v4.2.2.stable.official [15073afe3]
Addon Version
5.1.0
This plugin doesn't currently support Android (or iOS), though actually that's something I could probably do for GDScript and C++, just not C#.
This is a hacky solution, but it's the best I've got so far: use a feature flag, and then wherever you use ImGui, do this first:
var ImGui = ClassDB.instantiate("ImGui") # bad idea
You'll get a warning (SHADOWED_GLOBAL_IDENTIFIER), but the code should compile. It just has to be a local variable inside a function, not a member variable.
Actually this is a very bad solution, because it causes a significant memory leak.
Otherwise my notes here apply (I still need to update the documentation/examples):
#62 (comment)
OK, better solution. Try this:
var ImGui = Engine.has_singleton("ImGuiGD")
if ImGui:
ImGui.Begin("hello")
ImGui.End()
You still get the warning, but no leaks and you shouldn't even need a feature flag.
I'll add a slightly better solution in the next version, which has the same drawbacks but is less weird and broken than exploiting a bool like this.
OK, better solution. Try this:
var ImGui = Engine.has_singleton("ImGuiGD") if ImGui: ImGui.Begin("hello") ImGui.End()You still get the warning, but no leaks and you shouldn't even need a feature flag.
I'll add a slightly better solution in the next version, which has the same drawbacks but is less weird and broken than exploiting a bool like this.
Amazing!
It worked. Thank you.