Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Add a basic example for system ordering #7017

Closed
wants to merge 4 commits into from
Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 33 additions & 3 deletions crates/bevy_ecs/src/system/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,39 @@
//!
//! - **System Stages:** They determine hard execution synchronization boundaries inside of
//! which systems run in parallel by default.
//! - **Labeling:** First, systems are labeled upon creation by calling `.label()`. Then,
//! methods such as `.before()` and `.after()` are appended to systems to determine
//! execution order in respect to other systems.
//! - **Labels:** Systems may be ordered within a stage using the methods `.before()` and `.after()`,
//! which order systems based on their [`SystemLabel`]s. Each system is implicitly labeled with
//! its `fn` type, and custom labels may be added by calling `.label()`.
//!
//! [`SystemLabel`]: crate::schedule::SystemLabel
//!
//! ## Example
//!
//! ```
//! # use bevy_ecs::prelude::*;
//! # struct App;
//! # impl App {
//! # fn new() -> SystemStage { SystemStage::single_threaded() }
//! # }
//! # let mut app = SystemStage::single_threaded();
//! // Prints "Hello, World!" each frame.
//! app
//! .add_system(print_first.before(print_mid))
//! .add_system(print_mid)
//! .add_system(print_last.after(print_mid));
//! # let mut world = World::new();
//! # app.run(&mut world);
//!
//! fn print_first() {
//! print!("Hello");
//! }
//! fn print_mid() {
//! print!(", ");
//! }
//! fn print_last() {
//! println!("World!");
//! }
//! ```
//!
//! # System parameter list
//! Following is the complete list of accepted types as system parameters:
Expand Down