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 aCommand
struct you can add:
.foo; // This will throw an error
commands.add; // This will still work
commands
#[command(no_world)]
prevents generating a trait implementation againstWorld
orEntityWorldMut
.foo; // This will throw an error
commands.foo; // This will still work
world
#[command(name = T)]
will useT
for the generated method and related struct/trait names:
.bar;
bar;
commands.add;
commands
#[command(struct_name = T)]
will use this name for the generated struct:
.foo;
foo;
commands.add;
commands
#[command(trait_name = T)]
will use this name for the generated trait:
.foo;
foo;
commands.add;
commands
#[command(ecs = T)]
or#[command(bevy_ecs)]
to point the macro to the correct bevy crate if you don't usebevy
directly.
Compatibility
Bevy | Crate |
---|---|
0.13 |
0.3 |
0.12 |
0.1 , 0.2 |