A macro for creating bevy Commands and EntityCommands methods from functions.
Examples
use *;
/// Regular bevy systems can be used as commands, too
/// Commands may optionally return `&mut Self` to allow chaining command calls
// Commands may also run against the world directly
See also the example and tests
Attributes
The following attributes apply equally to #[command] and #[entity_command]
#[command(no_trait)]prevents generating a trait method for Commands, but will still generate aCommandstruct you can add:
commands.foo; // This will throw an error
commands.add; // This will still work
#[command(no_world)]prevents generating a trait implementation againstWorldorEntityWorldMut
world.foo; // This will throw an error
commands.foo; // This will still work
#[command(name = T)]will useTfor the generated method and related struct/trait names:
commands.bar;
bar;
commands.add;
#[command(struct_name = T)]will use this name for the generated struct:
commands.foo;
foo;
commands.add;
#[command(trait_name = T)]will use this name for the generated trait:
commands.foo;
foo;
commands.add;
#[command(ecs = T)]or#[command(bevy_ecs)]to point the macro to the correct bevy crate if you don't usebevydirectly.
Compatibility
| Bevy | Crate |
|---|---|
0.13 |
0.3 |
0.12 |
0.1, 0.2 |