Open van800 opened 4 years ago
Use messaging from https://github.com/JetBrains/godot-support/pull/102
Hello @van800.
After having a look, I think sending a ReloadScriptsRequest
from the messaging client is indeed a way to trigger a script reload.
I would like to try this approach, however, I'm not sure how to hook into the debugger to trigger this request when the user recompiles his project.
I've never written a rider plugin before so any pointers would be welcome :smile:
@geowarin why do you want to hook debugger, instead of the com.jetbrains.rider.build.BuildHost
?
I see messages on the internet saying hot reload works in VS with some simple trick without calling any tcp signals. https://www.reddit.com/r/godot/comments/16pjnt2/psa_c_hotreloading_works_with_this_one_simple/ So maybe we need to see VS and Rider side-by-side on windows to see what is different.
why do you want to hook debugger, instead of the
com.jetbrains.rider.build.BuildHost
?
I don't know, I thought this feature was only needed when running the game in debug mode? I don't know anything about rider extensions apologies if it sounds stupid :smile: I'll try to see if I can do something with BuildHost
Regarding, this message on reddit, I don't have VS to test but I really doubt that this works at all. In theory, hot reloading should happen when the LSP sends a didSave request to the engine.
But this is not working. AFAIK hot reloading does not work with external editors AT ALL. See: https://github.com/godotengine/godot/issues/72825
Since rider does not use LSP, I think we need to trigger this via another means.
Here are my other thoughts:
When the game is started from the GodotEditor, we can use messaging from https://github.com/JetBrains/godot-support/pull/102 to send signals to GodotEditor and it should be transmitted to the Game. However normally with Rider we start the Game directly from Rider. This is likely also blocked by the mentioned issue https://github.com/godotengine/godot/issues/72825.
What we want is actually to execute this 3 lines of code. Unfortunately, I can't find a way to do it. I can see the name of the script Godot.ScriptLanguageExtension.MethodName._ReloadAllScripts
, but not the way to call it from the Game.
Hack way to accomplish the task could be to start Game with --remote-debug 127.0.0.1:$port
, connect to it and send this to its buffer. Here is an example of SaveAll handler in Rider.
From what I understand, calling the ReloadScriptsRequest
from the IPC client introduced in the previous PR will call the
EditorDebuggerNode::reload_scripts() method.
I think you're right, this might only reload the current tabs or something like that. I'll need to test that.
This makes me question if EditorDebuggerNode::reload_scripts()
, which is callable from IPC, should do something similar to the 3 lines you pointed out, from the remote debugger:
for (int i = 0; i < ScriptServer::get_language_count(); i++) {
ScriptServer::get_language(i)->reload_all_scripts();
}
It would make sense to me at least. Maybe this can be accepted in a PR for the engine.
The hacky way seems feasible also, let me give it a try.
Hi, how is the progress on hot reloading gdscript? Would be very useful for us
There is a technical problem on the Rider side https://youtrack.jetbrains.com/issue/RIDER-102927. Unfortunately, it is not being prioritized.
Does this also apply to hot reloading gdscript? As only C# is mentioned in the issue you linked
RIDER-102927 is only about C#. @markusstephanides if you can explain the gdscript reload to me, it would help a lot.
If I change a .gdscript file in VS Code while the game is running (vs code didn't start the game, it is just connected to the Godot editor) and save the file, the changes will be immediately applied to the running game. I think this is also the case if you make changes to .gdscript files within the Godot editor.
Thank you, I can confirm the missing feature in comparison with vscode. I will investigate further. Created a separate issue https://youtrack.jetbrains.com/issue/RIDER-114380/Godot-HotReload-GDScript. We use those youtrack issues to plan iterations.
Thank you very much!
Like https://github.com/DavidKarlas/GodotExtension/blob/c3173c49db606bd35f9cc7687f8832442fe790c9/Godot/GodotDebuggerSession.cs#L19 sends GD.Var2Bytes(new Array().Add("reload_scripts"))
Todo:
--remote-debug 127.0.0.1:$port
reload_scripts
to that port. Usecom.jetbrains.rider.build.BuildHost
to receive event after build.