Godot Version
3.5.3 and 4.2.1
Question
I’m trying to develop a script to help import create lines and paths. I tried both an EditorScript that I just run using the Run menu or using an entry in the menu using add_tool_menu_item. Either way, I am having some issues and when I tried setting breakpoints by clicking on the side and adding little red dots, but when I run it, the script runs, I see the print statements printed but the debugger doesn’t pop up. Tried both in Godot 3 and 4.
Is there any special way to invoke an editor script so that I can debug it step-by-step?
Print statements is really the best and only way. It’s actually not so terrible.
It is kinda terrible. I’m trying to parse some external files and when using print statements Godot complained about printing too much.
Yes, its a limitation, but if you have that kind of issue, then create a function that prints only a few statements. There are workarounds depending what you want to do.
E,g, a count variable
var count=3
func _process(delta):
if count != 0:
print(delta, "something whatever")
count-=1
You can use an external editor for this. For example, with the VSCode plugin, you set your breakpoints in VSCode. Then, “Run and Debug” with your editor debug configuration. Finally, when you use Script → File → Run in Godot with your EditorScript, your breakpoints will hit in VSCode. Here’s an example launch.json configuration for VSCode (you would need to set Run and Debug to use the “GDScript: Launch Editor” configuration):
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "GDScript: Launch Editor",
"type": "godot",
"request": "launch",
"project": "${workspaceFolder}",
"debug_collisions": false,
"debug_paths": false,
"debug_navigation": false,
"additional_options": "--editor"
},
{
"name": "GDScript: Launch Game",
"type": "godot",
"request": "launch",
"project": "${workspaceFolder}",
"debug_collisions": false,
"debug_paths": false,
"debug_navigation": false,
"additional_options": ""
}
]
}