mirror of
https://github.com/bevyengine/bevy
synced 2024-11-26 06:30:19 +00:00
6d6bc2a8b4
This is extracted out of eb8f973646476b4a4926ba644a77e2b3a5772159 and includes some additional changes to remove all references to AppBuilder and fix examples that still used App::build() instead of App::new(). In addition I didn't extract the sub app feature as it isn't ready yet. You can use `git diff --diff-filter=M eb8f973646476b4a4926ba644a77e2b3a5772159` to find all differences in this PR. The `--diff-filtered=M` filters all files added in the original commit but not in this commit away. Co-Authored-By: Carter Anderson <mcanders1@gmail.com>
50 lines
1.4 KiB
Rust
50 lines
1.4 KiB
Rust
use bevy::{app::PluginGroupBuilder, prelude::*};
|
|
|
|
/// PluginGroups are a way to group sets of plugins that should be registered together.
|
|
fn main() {
|
|
App::new()
|
|
// Two PluginGroups that are included with bevy are DefaultPlugins and MinimalPlugins
|
|
.add_plugins(DefaultPlugins)
|
|
// Adding a plugin group adds all plugins in the group by default
|
|
.add_plugins(HelloWorldPlugins)
|
|
// You can also modify a PluginGroup (such as disabling plugins) like this:
|
|
// .add_plugins_with(HelloWorldPlugins, |group| {
|
|
// group
|
|
// .disable::<PrintWorldPlugin>()
|
|
// .add_before::<PrintHelloPlugin,
|
|
// _>(bevy::diagnostic::LogDiagnosticsPlugin::default()) })
|
|
.run();
|
|
}
|
|
|
|
/// A group of plugins that produce the "hello world" behavior
|
|
pub struct HelloWorldPlugins;
|
|
|
|
impl PluginGroup for HelloWorldPlugins {
|
|
fn build(&mut self, group: &mut PluginGroupBuilder) {
|
|
group.add(PrintHelloPlugin).add(PrintWorldPlugin);
|
|
}
|
|
}
|
|
|
|
pub struct PrintHelloPlugin;
|
|
|
|
impl Plugin for PrintHelloPlugin {
|
|
fn build(&self, app: &mut App) {
|
|
app.add_system(print_hello_system.system());
|
|
}
|
|
}
|
|
|
|
fn print_hello_system() {
|
|
info!("hello");
|
|
}
|
|
|
|
pub struct PrintWorldPlugin;
|
|
|
|
impl Plugin for PrintWorldPlugin {
|
|
fn build(&self, app: &mut App) {
|
|
app.add_system(print_world_system.system());
|
|
}
|
|
}
|
|
|
|
fn print_world_system() {
|
|
info!("world");
|
|
}
|