Public API for Jackdaw editor extensions.
Extensions are entities. An extension entity holds an [lifecycle::Extension]
component, and every registration (operators, windows, BEI contexts,
panel extensions) spawns child entities under it. Unloading an
extension is world.entity_mut(ext).despawn(); Bevy cascades through
the children and a few observers handle the non-ECS cleanup.
Minimal extension:
use bevy::prelude::*;
use bevy_enhanced_input::prelude::*;
use jackdaw_api::prelude::*;
#[operator(id = "sample.place_cube")]
fn place_cube(_: In<OperatorParameters>, mut commands: Commands) -> OperatorResult {
commands.spawn((Name::new("Cube"), Transform::default()));
OperatorResult::Finished
}
#[derive(Component, Default)]
struct SamplePluginContext;
#[derive(Default)]
struct MyCoolExtension;
impl JackdawExtension for MyCoolExtension {
fn name() -> String { "The coolest extension".into() }
fn register(&self, ctx: &mut ExtensionContext) {
ctx.register_operator::<PlaceCubeOp>();
ctx.spawn((
SamplePluginContext,
actions!(SamplePluginContext[
Action::<PlaceCubeOp>::new(),
bindings![KeyCode::KeyC],
]),
));
}
fn register_input_context(&self, app: &mut App) {
app.add_input_context::<SamplePluginContext>();
}
}