Quick answer: Branch on Engine.IsEditorHint in any heavy method. Avoid running game logic in the editor. Unsubscribe from events in _ExitTree to avoid stale handlers across editor reloads.

Editor freezes for seconds whenever you save the scene. A [Tool] script’s _Process is running pathfinding or simulation while the editor expects fast UI.

The Symptom

Editor lags or hangs after script changes or scene save. Game runs fine. Removing [Tool] removes the hang but loses editor preview.

The Fix

[Tool]
public partial class PathPreview : Node3D
{
    public override void _Process(double dt)
    {
        if (Engine.IsEditorHint)
        {
            // only do cheap work in the editor
            DrawPreview();
        }
        else
        {
            // full game logic at runtime
            RunSimulation(dt);
        }
    }
}

Branch on IsEditorHint. Editor preview stays light; runtime gets the full sim.

Editor-Only Code

public override void _Notification(int what)
{
    if (what == NotificationEditorPreSave && Engine.IsEditorHint)
    {
        // pre-save tasks: regenerate cached preview, etc.
    }
}

Verifying

Save the scene. Editor should respond instantly. Profile via Editor → Debugger → Frame Time during save to identify remaining hot spots.

“Branch on IsEditorHint. Skip heavy at edit time.”

Related Issues

For C# disposed wrapper, see disposed wrapper. For C# task background, see await background.

IsEditorHint guards. Editor breathes.