utopia-rise / godot-kotlin-jvm

Godot Kotlin JVM Module
MIT License
646 stars 45 forks source link

Is it possible to use Compose Multiplatform UI as an interface in Godot with this project? #561

Closed unicornlox closed 9 months ago

unicornlox commented 10 months ago

hello, is it possible to use Compose Multiplatform UI as an interface in godot game with this project or how can it be made possible?

MartinHaeusler commented 10 months ago

I'm not an expert but: I highly doubt it is possible. Compose Multiplatform UI relies on different UI technologies depending on the platform:

Godot brings its own UI system. While I do think that it might be possible (in theory) to write a backend for Compose Multiplatform UI that uses the Godot UI in the background, that would be a huge project in its own right.

Also: I don't think it's a good idea. Godot is a game engine with a main loop that runs once per frame. The UI is therefore also updated once per frame, always. This is contrary to regular UI frameworks (such as Compose) which try to limit re-drawing as much as possible.

Long story short: do yourself a favor and familiarize yourself with the Godot UI instead, it's not all that bad :)

unicornlox commented 10 months ago

@MartinHaeusler godot control node elements look very bad when the screen resolution changes and I have to keep track of the resolution of all nodes with code.I read that haxeui is available in hxgodot and I wondered if it was also possible in kotlin. thanks.

chippmann commented 9 months ago

Theoretically this is possible but as @MartinHaeusler already mentioned not really feasible. For one, you cannot directly interact with godot or the kotlin code which runs in godot from compose and vice versa. They function completely different.

So I highly advice against it.

chippmann commented 9 months ago

One thing you could look at however is using godot inside your native application as one ui element. Then you can write your ui in compose and your 3D or 2D godot view is just a view in there.

On android this is not that hard with AndroidView (see: https://docs.godotengine.org/en/latest/tutorials/platform/android/android_library.html) on iOS i never tried but should be doable as well. On the other platforms though: I have no clue

stashymane commented 3 weeks ago

Although using Compose Multiplatform in its entirety is very unlikely, you can definitely use the Compose compiler to create a Compose API for Godot UI components.