Skip to content

Commit

Permalink
Add a basic example for system ordering (bevyengine#7017)
Browse files Browse the repository at this point in the history
# Objective

Fix bevyengine#5653.

## Solution

- Add an example of how systems can be ordered from within a stage.
- Update some docs from before bevyengine#4224
  • Loading branch information
JoJoJet authored and ItsDoot committed Feb 1, 2023
1 parent cbf515a commit 3b7312b
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 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,35 @@
//!
//! - **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::*;
//! # 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

0 comments on commit 3b7312b

Please sign in to comment.