← Back to SKILL.md
Testing and Debugging Plugins
Reloading a plugin in the editor
The fastest way to reload plugin code without restarting Godot:
- Project → Project Settings → Plugins (Project Settings → Addons → Plugins on 4.8) → untick the plugin → tick it again.
- Alternatively, run this
EditorScriptfrom the script editor (File → Run, Ctrl+Shift+X; the script must be a@toolscript that extendsEditorScript):
# EditorScript — run with File → Run in the script editor.
@tool
extends EditorScript
func _run() -> void:
var plugin_name := "my_plugin"
# Disable then re-enable to force a clean reload cycle.
EditorInterface.set_plugin_enabled(plugin_name, false)
EditorInterface.set_plugin_enabled(plugin_name, true)
print("Plugin %s reloaded." % plugin_name)Do not reload by writing
editor_plugins/enabledthroughProjectSettings— that key holds every enabled plugin, so overwriting it disables all of them and re-enables none.
For quicker iteration, save the plugin script — Godot hot-reloads @tool scripts automatically. Complex changes (new class registrations, dock changes) require a full disable/enable cycle.
C# has a dedicated editor API for the same disable/enable cycle, so you do not have to go through ProjectSettings:
#if TOOLS
[Tool]
public partial class PluginReloader : EditorScript
{
public override void _Run()
{
var pluginName = "my_plugin";
// Disable then re-enable to force a clean reload cycle.
EditorInterface.Singleton.SetPluginEnabled(pluginName, false);
EditorInterface.Singleton.SetPluginEnabled(pluginName, true);
GD.Print($"Plugin {pluginName} reloaded.");
}
}
#endifC# plugin reload caveat: unlike GDScript, C# plugins require recompilation. After editing C# plugin source the editor must rebuild the assembly before re-enabling. If the plugin fails to load with "Unable to load addon script from path … This might be due to a code error in that script", the C# project most likely failed to compile — check the MSBuild Panel at the bottom of the editor for compilation errors.
Debugging with print
print() and push_error() / push_warning() output to the Godot Output panel and the OS console when Godot is launched from a terminal.
func _enter_tree() -> void:
print("[my_plugin] _enter_tree called") # Output panel
push_warning("[my_plugin] something unexpected")
push_error("[my_plugin] something failed") # also shown as red in Output// C# equivalent — same Output panel, same OS console.
#if TOOLS
public override void _EnterTree()
{
GD.Print("[my_plugin] _EnterTree called"); // Output panel
GD.PushWarning("[my_plugin] something unexpected");
GD.PushError("[my_plugin] something failed"); // also shown as red in Output
}
#endifTo see that output in a console on Windows, launch the console wrapper that ships next to the editor (…_console.exe); the main .exe is a GUI-subsystem program and does not attach to a terminal:
Godot_v4.3-stable_win64_console.exe --editor --path /path/to/projectPlugin lifecycle gotchas
| Situation | What happens | Fix |
|---|---|---|
Plugin enabled but _enter_tree crashes |
Plugin remains enabled but broken; editor may be unstable | Disable, fix, re-enable |
Forgot to remove a dock in _exit_tree |
Dock orphan survives disable; duplicate docks appear on next enable | Always null-check and queue_free() in _exit_tree |
| Custom type still listed after removal | Usually a missing remove_custom_type() in _exit_tree() |
Add the call; restart the editor if the entry persists |
@tool script crashes on property set |
Editor shows the error but the script stops updating | Guard with if Engine.is_editor_hint() and validate inputs |
| C# plugin not compiling | Plugin fails to load with "Unable to load addon script from path …" | Click the icon-only Build Project button in the top-right run bar, left of the Play button (Alt+B; .NET editor only), then read the MSBuild panel and fix C# errors first |
add_inspector_plugin called twice |
Inspector plugin fires twice per property | Track and guard with a null-check before add_inspector_plugin |