Expand description
§bevy-butler
A set of procedural macros for making Bevy plugins and systems more self-documenting.
§Version Compatibility
| bevy | bevy-butler |
|---|---|
0.17 | 0.7 |
0.16 | 0.6 |
0.15 | 0.5 |
§Example
use bevy::prelude::*;
use bevy_butler::*;
#[butler_plugin]
struct MyPlugin;
#[derive(Resource)]
#[insert_resource(plugin = MyPlugin, init = Hello("World".to_string()))]
struct Hello(String);
#[add_system(schedule = Update, plugin = MyPlugin)]
fn hello_plugin(name: Res<Hello>)
{
info!("Hello, {}!", name.0);
}
#[add_system(schedule = Update, plugin = MyPlugin, after = hello_plugin)]
fn goodbye_plugin(name: Res<Hello>)
{
info!("Goodbye, {}!", name.0);
}
fn main() {
App::new()
.add_plugins(MyPlugin)
.run();
}§WebAssembly support
WebAssembly support is currently locked behind the wasm-experimental flag. See the relevant issue for more information.
Attribute Macros§
- add_
message - Registers the annotated
Messageupon the given#[butler_plugin]being built. - add_
observer - Registers an observer function to a
#[butler_plugin]-annotatedPlugin. - add_
plugin - Adds the given
Pluginto the targetPlugin/PluginGroup - add_
plugin_ group - Adds the given
PluginGroupto the targetPlugin/PluginGroup - add_
sub_ state - Adds the annotated sub state to a
#[butler_plugin] - add_
system - Registers a system to a
#[butler_plugin]-annotatedPlugin. - butler_
plugin - Configures a plugin to be usable within bevy_butler’s various macros
as a
pluginargument. - butler_
plugin_ group - Implements
PluginGroupand configures it to be used withadd_plugin/add_plugin_group. - insert_
resource - Registers the annotated
Resourceto a#[butler_plugin]and initializes it upon the plugin being added. - insert_
state - Adds the annotated state to a
#[butler_plugin] - register_
type - Registers the annotated
Reflecttype into the app’s type registry for reflection.