Crate bevy_registration

Crate bevy_registration 

Source
Expand description

§Bevy Registration

Annotate systems, resources, and events with macros and automatically add them to your app. This uses Inventory internally, so it may not work on all targets.

§Example:

use bevy::prelude::*;
use bevy_registration::prelude::*;

// Initiates the resource on the app.
#[init]
#[derive(Resource, Default)]
pub struct TestResource;

// Adds the system to the Update schedule.
#[system(Update)]
fn resource_tester(resource: Option<Res<TestResource>>) {
    // This will not panic.
    resource.unwrap();
}

fn main() {
    App::new()
        // Add bevy's default plugins, to start up the update loop.
        .add_plugins(DefaultPlugins)
        // Add the registration plugin that will collect the far-away app code.
        .add_plugins(RegistrationPlugin)
        .run();
}

Modules§

prelude

Macros§

app
Runs a function on the app from anywhere. Accepts a closure or a function’s ident. Expects an input of &mut app, with no output. Example:

Structs§

RegistrationPlugin
Iterates through the collected app functions and runs each of them.

Functions§

try_run_schedule
A system that will try to run a schedule. This is used internally.