Editor plugins

Using EditorPlugin types is very similar to the process used when writing plugins in GDScript. Unlike GDScript plugins, godot-rust plugins are registered automatically and cannot be enabled/disabled in the Project Settings plugins pane.

Plugins written in GDScript are automatically disabled if they have a code error, but because Rust is a compiled language, you cannot introduce compile-time errors.

Creating an EditorPlugin

fn main() {
#[class(tool, init, editor_plugin, base=EditorPlugin)]
struct MyEditorPlugin {
    base: Base<EditorPlugin>,

impl IEditorPlugin for MyEditorPlugin {
    fn enter_tree(&mut self) {
        // Perform typical plugin operations here.

    fn exit_tree(&mut self) {
        // Perform typical plugin operations here.

Since this is an EditorPlugin, it will be automatically added to the scene tree root. This means it can access the scene tree at runtime. Additionally, it is safe to access the EditorInterface singleton through this node, which allows adding different GUI elements to the editor directly. This can be helpful if you have an advanced GUI you want to implement.

Gameplay-only code

Use an is_editor_hint guard if you don't want some code executing during runtime of the game.

Read more information on guard clauses in computer science.