Description
Godot version
v4.2.2.stable.official [15073afe3]
godot-cpp version
4.2 [9da6ecd]
System information
Windows 10, Intel Core i5-9300H
Issue description
Testing out the new hot-reloading feature, I have observed that changes do not appear in the editor view after recompiling a GDExtension. Or let's say, they only appear partly.
Two examples where I encountered this:
- Attributes like changed text labels on buttons appear when running a scene, but not in editor view. This remains unchanged regardless of running the scene. (For example, set some text upon
_ready()
and change it every time a button is pressed.) The only fix I see so far is to reload the project. - Consider renaming a method binding for a signal: It will be shown in it's updated version when picking a method for a signal via the "Connect a Signal to a a Method" prompt, but not in the node's inspector. Even worse, Godot still considers the old name to exist and doesn't complain when running the scene, even though the method does no longer exist due to the renaming.
In order to visualize what I mean (I'll also provide a minimal reproducible example project), I'll detail those two examples now. Let's say we start with this in a button class:
void StartStopButton::_ready() {
this->set_text("Start Moving");
}
void StartStopButton::_pressed() {
if (!flipMode)
this->set_text("Stop Moving");
else
this->set_text("Start Moving");
flipMode = !flipMode;
}
This is reflected in the editor view:
However, now change the text in the code, compile and see that the change is not reflected within the editor view. But, if the scene / game is run, the changes are correctly shown.
Now an example for renamed method bindings. Let's say we have a method like:
void GDExample::_on_startstop_button_pressed() {
move = !move;
}
in the Sprite2D child. (And correctly bound in the _bind_methods()
method.) This method is connected to the pressed()
signal of the button. Rename it to something else, for example on_start_button_pressed
, recompile and then we have this:
The old name of the connected method is still visible:
If I now double click on the signal in order to pick another method, and I'm looking for the renamed one, it is correctly listed:
Yielding two methods, if the connection to the old one is not removed:
Running the scene like that is totally fine. Which is good but also problematic as I would expect Godot to throw an error or display an error message if the outdated signal handler can not be called. Which it really can't as it does not exist anymore in the code and resulting library.
If the whole project is reloaded after recompiling the code, those issues disappear. But that's not what I would expect from hot reloading.
Steps to reproduce
- Create a C++ GDExtension project.
- Create some node which should have visible changes in the editor, like a labeled button or a method name for signal handling.
- Compile.
- Change something about it in the code, e.g., the text label or the method name.
- Compile again.
- See that the changes are not or only partly reflected in the editor, but running the game or scene is fine.
Minimal reproduction project
The minimal example, which I provided, should be fine to use for that. Note, that you need to change the env
path in the SConstruct
file as I placed the godot-cpp compiled C++ API in a different directory and left the path in a probably unusable state now. And of course, don't forget to compile otherwise Godot will not find the libraries as I have not bundled them with the zip archive.