VScode + C# + Hot Reloading

Godot Version

4.4.1-stable_mono

Question

I’m trying to get Godot, C# and VsCode working together. I followed the gamesfromscratch.com tutorial and stuff seems to be working fairly well. I’ve got intellisense, I can see my scene, I can click on a script to open it in the editor, etc…

However the one thing I can’t get to work is auto-reload. A Google search seems to reveal this is supported and if I run my game, edit a file, save it the changes should be auto-reloaded.

This doesn’t seem to work for me even on a simple script like:

using Godot;
using System;

public partial class Main : Node3D
{
    public override void _Process(double delta)
    {
        // This method is called when the node is added to the scene.
        GD.Print("Loop.");
    }

}

When running the above I can see “Loop.” in my console and I would expect that changing the GD.Print string would reload the script, but no such thing happens.

I did find a setting called text_editor/behavior/files/auto_reload_scripts_on_external_change but even setting this “On” didn’t change much.

Am I missing something? Any help would be greatly appreciated!

Update: Attempted hot reload with GDScript and it works, so I assume it’s either:

  • a Mac issue
  • Missing config on my part
  • C# quirk

The C# parser doesn’t run until you try to build it, so I’d imagine it doesn’t need to autoreload (unless you mean it tries to compile from outdated cached info)

I’m not familiar with Godot terms but when writing in GDScript I can:

  1. Start the game
  2. Go into my script
  3. Update it
  4. The currently running game will reload the script without stopping and restarting

This is the behavior I’m looking for with C#.

Ok so GDscript is interpreted (meaning exactly what you write, it runs) whereas C# is compiled (so before it can run it makes a version of it in bytecode) and because of that neither the error checker nor the game will pick up on changes you’ve made until you click either the hammer icon in the top right or press play. That also means you can’t change the code while the game is running

Ah fair enough, that’s unfortunate! I’ll try my hand at GDScript then

1 Like

Wait I lied apparently C# does have dynamic recompile functionality, no idea how to do that in Godot but I ought to tell you

1 Like

Right that’s what was confusing me, I Googled and a bunch of people said it did work for them.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.