reckfellENGINE

C# in the editor: Tool and lifecycle

Separate editor context and clean up owned registrations.

On this page

[Tool] allows a C# script to run during editing. It does not launch a game level or register a plugin: EditorPlugin still needs configuration and enablement.

Separate contexts

Engine.IsEditorHint() indicates editor context. In shared scripts, separate editor preview work from gameplay logic. Do not use EditorInterface during an ordinary game launch as if the editor were open.

Complete [Tool] example: SceneAuditPlugin. Its _EnterTree() creates an owned panel/menu; _ExitTree() unregisters them, disconnects the button, and frees the panel. The test confirmed Engine.IsEditorHint()==true in the real editor.

For callbacks in other classes, account for context and object availability. Do not start game networking, microphone capture, or file changes merely from a tool-class constructor: scripts can be instantiated during editor scanning/loading.

Lifecycle

Reenabling creates a new EditorPlugin instance. Initialize on entry and clean up symmetrically on exit. A C# reference does not keep a freed native Entity alive; stop using a queued panel as an active object.

Do not remove other plugins' panels or the edited root to clean up yours. RemoveDock() unregisters a dock; separately free your owned object. Cleanup should tolerate partially completed setup.

Editing project content

The example only reads the current hierarchy. A tool changing properties or creating/removing Entities needs the edited target, UndoRedo, and correct Owner for saved objects. Assigning a property does not automatically create a complete undoable editor command.

EditorScript._Run() serves a separately launched operation, not the _EnterTree()/_ExitTree() lifecycle of a persistent plugin. Its execution was not tested by this suite.

Tool EditorPlugin context, activation/deactivation, callbacks, and cleanup were checked in a separate project. Gameplay branches, EditorScript, undoable scene edits, and exports were not.

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.