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

[DRAFT] GDExtension: Support hot-reloading in game #97991

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dsnopek
Copy link
Contributor

@dsnopek dsnopek commented Oct 8, 2024

This adds a project setting (editor/run/enable_extension_reloading) that will enable hot-reloading GDExtensions in the game when run with the play button from the editor. (Currently, hot-reloading only happens in the editor itself, which is nice because you can see properties/signals/etc update, but doesn't let you "live edit" the game as it's running.)

It works in some really rudimentary testing on Linux.

However, I'm pretty sure this is going to have problems on Windows with the DLL copying stuff. I'd like to do more testing, including on multiple platforms, before taking this out of draft.

@dsnopek dsnopek added this to the 4.x milestone Oct 8, 2024
@dsnopek dsnopek requested review from a team as code owners October 8, 2024 19:04
@dsnopek dsnopek marked this pull request as draft October 8, 2024 20:17
@dsnopek
Copy link
Contributor Author

dsnopek commented Oct 8, 2024

Thinking about this some more, this might make more sense (from a UI perspective) as a checkbox in the "Debug" menu, like "Synchronize Scene Changes" and "Synchronize Script Changes". I'm not sure if it'd fit in from a technical perspective, though.

@@ -1009,6 +1009,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
bool use_custom_res = true;
bool force_res = false;
bool delta_smoothing_override = false;
bool gdextension_reload_in_game = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should fix the unused-variable errors

Suggested change
bool gdextension_reload_in_game = false;
#ifdef TOOLS_ENABLED
bool gdextension_reload_in_game = false;
#endif // TOOLS_ENABLED

@dandersch
Copy link

@dsnopek Thanks for implementing this so quickly.

I can't confirm that this is working in a basic project on Linux.

I'm using the godot-cpp bindings on branch 4.3 for the extension and I run the editor with --gdextension-reload and with "Enable Extension Reloading" turned on (running with only --gdextension-reload doesn't seem to do anything). When running the game with the play button and then recompiling the extension with a change, after focusing the editor, the change is reflected inside the editor, but the changed node just disappears inside the game window (the node being just a moving godot icon sprite).

I also have the problem that the editor only ever hot-reloads the extension when I refocus the editor, i.e. not while I stay actively on it. That's probably unrelated to this commit, I just wonder if it's like this for others.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants