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

Send hot-reload signals #3

Open
van800 opened this issue Mar 10, 2020 · 14 comments
Open

Send hot-reload signals #3

van800 opened this issue Mar 10, 2020 · 14 comments
Labels
good first issue Good for newcomers

Comments

@van800
Copy link
Collaborator

van800 commented Mar 10, 2020

Like https://github.com/DavidKarlas/GodotExtension/blob/c3173c49db606bd35f9cc7687f8832442fe790c9/Godot/GodotDebuggerSession.cs#L19 sends
GD.Var2Bytes(new Array().Add("reload_scripts"))

Todo:

  1. start listening to tcp $port
  2. start game with additional argument --remote-debug 127.0.0.1:$port
  3. After each build, send reload_scripts to that port. Use com.jetbrains.rider.build.BuildHost to receive event after build.
@van800 van800 added the good first issue Good for newcomers label Nov 5, 2020
@van800
Copy link
Collaborator Author

van800 commented Jun 28, 2023

Use messaging from #102

@geowarin
Copy link

geowarin commented Sep 28, 2023

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 😄

@van800
Copy link
Collaborator Author

van800 commented Sep 29, 2023

@geowarin why do you want to hook debugger, instead of the com.jetbrains.rider.build.BuildHost?

@van800
Copy link
Collaborator Author

van800 commented Sep 29, 2023

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.

@geowarin
Copy link

geowarin commented Sep 29, 2023

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 😄
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: godotengine/godot#72825

Since rider does not use LSP, I think we need to trigger this via another means.

@van800
Copy link
Collaborator Author

van800 commented Sep 29, 2023

Here are my other thoughts:

  1. When the game is started from the GodotEditor, we can use messaging from Add Input Action and NodePath completion #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 Hot-reloading of scripts ("Synchronize Script Changes") doesn't work when using external editor (VSCode) godotengine/godot#72825.

  2. 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.

  3. 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.

@geowarin
Copy link

geowarin commented Sep 29, 2023

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.

@markusstephanides
Copy link

Hi, how is the progress on hot reloading gdscript? Would be very useful for us

@van800
Copy link
Collaborator Author

van800 commented Jul 7, 2024

There is a technical problem on the Rider side https://youtrack.jetbrains.com/issue/RIDER-102927. Unfortunately, it is not being prioritized.

@markusstephanides
Copy link

Does this also apply to hot reloading gdscript? As only C# is mentioned in the issue you linked

@van800
Copy link
Collaborator Author

van800 commented Jul 7, 2024

RIDER-102927 is only about C#.
@markusstephanides if you can explain the gdscript reload to me, it would help a lot.

@markusstephanides
Copy link

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.

@van800
Copy link
Collaborator Author

van800 commented Jul 7, 2024

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.

@markusstephanides
Copy link

Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants