Quick answer: Wrap editor-only calls with Engine.IsEditorHint(). Confirm referenced assemblies are present in export. Disable editor-only NuGet packages at runtime.

A C# editor tool script (e.g. custom inspector helper) builds in editor fine. Export to Windows throws “type not found” or NullRef. Editor-only code shipping with runtime.

Guard with IsEditorHint

[Tool]
public partial class EditorHelper : Node
{
    public override void _Ready()
    {
        if (!Engine.IsEditorHint()) return;
        // editor-only setup
    }
}

Tool scripts run in editor and runtime. Early-out at runtime if behavior is editor-only.

Conditional Compilation

#if TOOLS
using Godot.EditorTools;
#endif

Excludes editor-only types from runtime build entirely. Godot defines TOOLS in editor build.

Export Preset

Verify Resources tab in export preset: editor-only scripts (under addons/) shouldn’t be exported. Use export filter *.cs, *.tscn minus addons subfolder.

NuGet Reference Pruning

Some editor-only packages (Godot.SourceGenerators, custom inspector libs) shouldn’t ship. Edit .csproj:

<PackageReference Include="MyEditorTool" Version="1.0.0">
  <ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>

Verifying

Export to all targets. No build errors. Run exported game; no missing-type runtime exceptions. Editor still works in IDE mode.

“Tool scripts walk a line between editor and runtime. Mark, guard, and exclude.”

Add [Conditional("TOOLS")] to editor-only methods — calls vanish in runtime, no need for if-guard sprinkling.