I’m still poking at this.
Tl;dr: You get different partial functionality with VSCode debugging depending on whether you include the debug and debug server ports in the launch.json
file for the VSCode plugin debugger.
I am first opening the editor, then clicking a script icon on a node to open VSCode, and then running from VSCode by going to the debug panel and clicking the green “play” icon. With my current settings, when I run in VSCode, the focus appears to change to the editor, and it looks like the editor is actually starting the game. This is new from my last post, and it is definitely caused by using the launch.json
config from the Godot docs, which includes the debug port and debug adapter/server port rather than the “minimal” config in the godot-tools Github readme.
My current settings:
Godot editor version: 4.2.2, Windows
godot-tools plugin for VSCode version: 2.0
In the editor:
- Debug > Synchronize Scene Changes is checked
- Editor Settings > Text Editor > Use External Editor is checked. Exec Flags are
{project} --goto {file}:{line}:{col}
.
- Editor Settings > Network > Debug > Remote Port is port 6007.
- Editor Settings > Network > Debug Adapter > Remote Port is port 6006. Sync Breakpoints is checked.
- Editor Settings > Network > Language Server > Remote Port is 6005, and I’ve checked Enable Smart Resolve, Show Native Symbols in Editor, and Use Thread.
In VSCode, in the settings for the godot-tools plugin:
- Editor path: C:\dev\Godot_4.2.2\Godot_v4.2.2-stable_win64.exe (I mention this because I once did a test using the 4.2 editor while this path was set to the 4.3 version of the editor, and nothing complained, which is unexpected)
- I do not have headless LSP checked
- LSP server host is 127.0.0.1
- LSP server port is 6005
In VSCode, in the launch.json config (accessed by going to the debug panel and clicking the gear next to the green play button and configuration pulldown):
"version": "0.2.0",
"name": "GDScript Godot",
"type": "godot",
"request": "launch",
And additionally, I’ve tested including and not including these three lines from the official docs:
"project": "${workspaceFolder}",
"port": 6007,
"debugServer": 6006,
As I wrote above, if I do not include these three lines, then, when I run the game from VSCode, VSCode itself appears to launch it rather than switching focus to the editor first. I cannot hot reload, meaning that changes to the script do not appear in the game upon save. In VSCode I get my print()
statements only through the VSCode debug panel, not in the editor’s output panel, and I can use the VSCode debugger’s Active Scene Tree and inspect nodes. I can use break points, and I can even step into the line that I changed. When I hover over the string variable that I changed, it shows the script’s original value rather than the new value I provided to try to hot reload. Also, in the Godot editor, there is no Remote view available for the scene, and my print()
statements do not appear in the output panel.
If I do include these three lines, then, when I run the game from VSCode, focus switches to the editor, which seems to run the scene. I can hot reload by editing a script in VSCode, but I cannot view the Active Scene Tree (it says Scene Tree data has not been requested
and clicking the refresh icon does nothing). I can use breakpoints in VSCode, and it shows the call stack and variables in the debug panel. Hovering over a variable in the script does not show the variable value, instead it gives me a little definition of the member variable. My print()
output goes to both the editor output window and to VSCode’s debug console.
Perhaps this information is meaningful to someone with better knowledge of how any of this works. My next step will be to clean up this information and make a Reddit post, since I know DaelonSuzuka, who appears to be the main dev of the VSCode plugin, has posted on Reddit before. Also, maybe someone there will point out something wrong with my configuration. Then, I suppose I’ll make a bug report for the plugin in Github, although I’ve never made a bug report before.