forked from bevyengine/bevy
-
Notifications
You must be signed in to change notification settings - Fork 6
/
plugin_group.rs
57 lines (47 loc) · 1.56 KB
/
plugin_group.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//! Demonstrates the creation and registration of a custom plugin group.
//! [`PluginGroup`]s are a way to group sets of plugins that should be registered together.
use bevy::{app::PluginGroupBuilder, prelude::*};
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(
// HelloWorldPlugins
// .build()
// .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(self) -> PluginGroupBuilder {
PluginGroupBuilder::start::<Self>()
.add(PrintHelloPlugin)
.add(PrintWorldPlugin)
}
}
pub struct PrintHelloPlugin;
impl Plugin for PrintHelloPlugin {
fn build(&self, app: &mut App) {
app.add_system(print_hello_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);
}
}
fn print_world_system() {
info!("world");
}