bevy_derive_commands

Crates.iobevy_derive_commands
lib.rsbevy_derive_commands
version0.1.2
sourcesrc
created_at2023-12-10 01:33:27.360559
updated_at2023-12-10 01:46:49.254679
descriptionA macro for creating bevy Commands methods
homepage
repositoryhttps://github.com/thebluefish/bevy_derive_commands
max_upload_size
id1063977
size18,300
(thebluefish)

documentation

README

crates.io

Derive macro for creating bevy Commands methods.

Example

use bevy_derive_commands::*;

/// A command that spawns a bundle `n` times
#[command]
fn create_stuff<B: Bundle + Clone>(world: &mut World, bundle: B, n: usize) {
    for _ in 0..times {
        world.spawn(bundle.clone());
    }
}

fn setup(mut commands: Commands) {
    // Use the generated method
    commands.create_stuff(TransformBundle::default(), 3);
    // Or add the generated command type directly
    commands.add(CreateStuffCommand { bundle: TransformBundle::default(), n: 3 });
}

Compatibility

Bevy Crate
0.12 0.1
Commit count: 8

cargo fmt