Hazel

In-Workspace Plugins

Almost every engine feature is its own Bevy plugin, in its own crate under crates/. This page covers that kind: a plugin compiled into the engine binary. It assumes you have the engine repository; see Building from Source.

There are exactly two kinds of plugin, and the question that separates them is whether the code ships with the engine or is installed beside it:

Crate typeBuiltShips in
In-workspace (this page)rlib under crates/with the engine, statically linkedthe engine binary
Native (Native Plugins)dylib in <exe dir>/plugins/<name>/on the machine that installs it, against the staged SDKthe editor, as source

Something that ships with the engine is a crate here. Something standalone, that a user chooses to install, is a native plugin. There is no third kind.

A plugin is a Bevy plugin

There is no Renzora plugin trait. A plugin is any type implementing Bevy's Plugin, plus Default:

// crates/renzora_glow/src/lib.rs
use bevy::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Component, Clone, Debug, Reflect, Serialize, Deserialize, Default)]
#[reflect(Component, Serialize, Deserialize)]
pub struct GlowSettings {
    pub intensity: f32,
}

#[derive(Default)]
pub struct GlowPlugin;

impl Plugin for GlowPlugin {
    fn build(&self, app: &mut App) {
        app.register_type::<GlowSettings>()
            .add_systems(Update, apply_glow.run_if(any_match_filter::<Changed<GlowSettings>>));
    }
}

fn apply_glow(query: Query<&GlowSettings, Changed<GlowSettings>>) {
    for settings in &query {
        // ...
    }
}

crates/renzora_oit is a complete, small, real example of exactly this shape: one component, one sync system gated on change, one plugin.

Declaring it

The crate declares its plugins in its own Cargo.toml, one table per plugin:

[package]
name = "renzora_glow"
version = "0.1.0"
edition = "2021"

[dependencies]
bevy = { workspace = true }
serde = { version = "1", features = ["derive"] }

[lints]
workspace = true

[[package.metadata.renzora.plugin]]
type = "GlowPlugin"
KeyRequiredMeaning
typeyesThe plugin type's path from the crate root: "GlowPlugin", or "material::MaterialPlugin" for one in a module
scopeno"Runtime" (the default) or "Editor"
prioritynoAn integer, default 0. Lower installs earlier

That is the whole job. Drop the crate into crates/ (the workspace members glob crates/renzora_* and crates/renzora_*/editor pick it up) and build with cargo renzora dist.

What reads the table

It is not a runtime registry. The table is configuration read by one program, the generator in xtask/src/sync.rs (manifest_plugins), which runs at the start of every cargo renzora build and standalone as cargo renzora sync. The crate never compiles anything for it, so a crate needs no contract dependency just to be a plugin.

The generator writes, for each of the two hosts (renzora_runtime for Runtime scope, renzora_editor for Editor scope):

  1. A generated block in the host's Cargo.toml [dependencies], with one plain path entry per plugin crate that is not already listed by hand. Cargo cannot do this itself: [dependencies] has no glob, and a build.rs runs after the dependency graph is resolved.
  2. src/plugins.rs, an ordinary list of app.add_plugins(path::Type::default()); calls, ordered by priority and then by path so an unrelated edit never reshuffles the file.

Both outputs are committed, so a plain cargo check --profile dist needs no generator run. CI runs cargo renzora sync --check, which regenerates into memory and fails if the result differs from what is on disk: a stale list cannot ship.

A named type in a generated list is just a linker symbol. There is no FFI, no registry iterated at startup, and nothing that can silently fail to register.

Mistakes are loud

  • The parser is strict. An unknown key, an unknown scope, a priority that is not an integer, or a table without type stops the generator with the manifest named.
  • A plugin declared twice is an error, because Bevy panics on a plugin added twice and the generator can see the mistake first.
  • A wrong type name or a missing Default impl is a compile error in the generated plugins.rs, not in your crate. Read the path it names.
  • Keep every module on the type path pub. A #[cfg(feature = "x")] pub mod y; gate on that path is detected and reproduced as a #[cfg] on the install line.

Several tables in one crate are fine: one per plugin.

Legacy form. A single-line renzora::add!(MyPlugin, Editor); in source is still read by the generator, for crates written before the manifest table. Declaring a plugin both ways is reported as a duplicate. Use the table.

Scopes

A scope is exactly one of two:

ScopeIn the editorIn a shipped gameFor
Runtime (default)yesyesgameplay, rendering, audio, networking, game UI: anything the game itself runs
Editoryesnopanels, inspectors, gizmos, import tools

There is no "both" scope. A feature that needs editor tooling on top of runtime behaviour ships two plugins, in two crates: the runtime crate crates/renzora_<name>/ and its editor half nested in crates/renzora_<name>/editor/ as renzora_<name>_editor. renzora_oit is the template again: OitPlugin is Runtime, and crates/renzora_oit/editor declares OitEditorPlugin with scope = "Editor" and registers the inspector section. The runtime crate stays lean, with no editor dependencies at all.

The editor is a loadable image beside the binary (renzora_editor.<dll|so|dylib>): present, and the binary is the editor; absent, and the same binary is the game. Editor-scope plugins live in that image, which is why they cannot reach a game. See Architecture.

Priority

priority orders installation. Reach for it only when a plugin must initialise a resource that another plugin reads inside its own build. Ordinary system ordering belongs to Bevy: system sets, .before(), .after(), .chain().

Making a plugin strippable from game exports

A newly discovered crate gets a plain, non-optional dependency: it is always compiled and always installed. Deciding which features a lean game export may leave out, and how they group, is an editorial choice the generator does not make.

To make one strippable, move its entry out of the generated block in crates/renzora_runtime/Cargo.toml, mark it optional = true, and add it to a feature:

[features]
oit = ["dep:renzora_oit"]

[dependencies]
renzora_oit = { path = "../renzora_oit", optional = true }

The generator leaves hand-written entries alone and reads the gate back out of the manifest, so the install line in plugins.rs gets the matching #[cfg(feature = "oit")]. That is how every optional engine feature is wired today.

Removing a crate

Use cargo renzora remove <crate>, not a plain delete. Cargo refuses to load a workspace whose manifest names a dependency directory that is missing, which would also stop it building the generator that repairs the manifest. remove prunes every reference (the dependency entry and any feature items that mention it) before deleting the directory, then re-syncs.

Keep dependencies thin

An engine crate depends on the contract layers it uses (crates/api/renzora_*_api), never on another engine crate's implementation and never on renzora_sdk. When a type has to cross a crate boundary, move it into the contract rather than depending on the crate that defines it. That is also what lets a native plugin reach the same type later, since plugins can link the contract and nothing else. See Architecture for the layers.

What a plugin can do

Inside build(&self, app) a plugin has the full &mut App. Beyond ordinary Bevy:

  • Scene data. Derive Reflect, Serialize and Deserialize, register the type, and the component saves and loads with scenes. A field added to a component later needs #[reflect(default)], or scenes saved before it existed fail to load. Only entities with a Name are written to a scene.
  • Editor surface from an Editor-scope plugin: inspector sections, presets, shortcuts, viewport tools. See Editor API and Editor Panels.
  • Script functions. A domain crate declares its own functions for every language backend. See Script Extensions.
  • Talking to other plugins without a crate dependency, through the plugin bus.
  • Backends for the subsystems that are behind a trait: audio, HTTP and physics.

Scaffolding

The renzora add <name> command of the separately installed renzora CLI runs docker/add-plugin.sh in the Linux container. That script predates the manifest table and the move of the contract crate to crates/shared/renzora, so writing the two files above by hand is the reliable route today.

See also