#registration #away #far #bevy #resources #procedural #init

macro bevy_registration_procedural_macros

Run code on the app from far away. Only the procedural macros are in this crate.

5 releases

new 0.2.3 Jan 15, 2025
0.2.2 Jan 15, 2025
0.2.1 Jan 15, 2025
0.2.0 Jan 14, 2025
0.1.0 Jan 6, 2025

#1769 in Procedural macros

Download history 136/week @ 2025-01-03 295/week @ 2025-01-10

431 downloads per month
Used in bevy_registration

MIT/Apache

12KB
204 lines

Bevy Registration

A way of running code on bevy's app from anywhere. This uses Inventory internally, so it may not work on all targets.

Useful documentation

TO DO

Example:

use bevy::{app::{App, Startup}, prelude::{Res, Resource}};

// Initiates the resource on the app.
// This does not need to be in the same module as the app. It can be anywhere.
#[init]
#[derive(Resource, Default)]
pub struct TestResource;

fn main() {
  App::new()
    // Add the registration plugin that will collect the far-away app code.
    .add_plugins(RegistrationPlugin)
    // This will not panic.
    .add_systems(Startup, |resource: Option<Res<TestResource>>|{resource.unwrap();})        
    .run();
}

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~265–710KB
~16K SLoC