| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
use bevy::{app::PluginGroupBuilder, prelude::*}; |
| 5 |
|
| 6 |
fn main() { |
| 7 |
App::new() |
| 8 |
.add_plugins(( |
| 9 |
|
| 10 |
DefaultPlugins, |
| 11 |
|
| 12 |
HelloWorldPlugins, |
| 13 |
)) |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
.run(); |
| 24 |
} |
| 25 |
|
| 26 |
|
| 27 |
pub struct HelloWorldPlugins; |
| 28 |
|
| 29 |
impl PluginGroup for HelloWorldPlugins { |
| 30 |
fn build(self) -> PluginGroupBuilder { |
| 31 |
PluginGroupBuilder::start::<Self>() |
| 32 |
.add(PrintHelloPlugin) |
| 33 |
.add(PrintWorldPlugin) |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
struct PrintHelloPlugin; |
| 38 |
|
| 39 |
impl Plugin for PrintHelloPlugin { |
| 40 |
fn build(&self, app: &mut App) { |
| 41 |
app.add_systems(Update, print_hello_system); |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
fn print_hello_system() { |
| 46 |
info!("hello"); |
| 47 |
} |
| 48 |
|
| 49 |
struct PrintWorldPlugin; |
| 50 |
|
| 51 |
impl Plugin for PrintWorldPlugin { |
| 52 |
fn build(&self, app: &mut App) { |
| 53 |
app.add_systems(Update, print_world_system); |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
fn print_world_system() { |
| 58 |
info!("world"); |
| 59 |
} |