diff --git a/examples/README.md b/examples/README.md index 36e5bbf0b5b1c..7174cd953e410 100644 --- a/examples/README.md +++ b/examples/README.md @@ -159,7 +159,7 @@ Example | File | Description `component_change_detection` | [`ecs/component_change_detection.rs`](./ecs/component_change_detection.rs) | Change detection on components `event` | [`ecs/event.rs`](./ecs/event.rs) | Illustrates event creation, activation, and reception `fixed_timestep` | [`ecs/fixed_timestep.rs`](./ecs/fixed_timestep.rs) | Shows how to create systems that run every fixed timestep, rather than every tick -`generic_system` | [`ecs/generic_system.rs`](./ecs/generic_system.rs) | Shows how to create generic systems +`generic_system` | [`ecs/generic_system.rs`](./ecs/generic_system.rs) | Shows how to create systems that can be reused with different types `hierarchy` | [`ecs/hierarchy.rs`](./ecs/hierarchy.rs) | Creates a hierarchy of parents and children entities `iter_combinations` | [`ecs/iter_combinations.rs`](./ecs/iter_combinations.rs) | Shows how to iterate over combinations of query results. `parallel_query` | [`ecs/parallel_query.rs`](./ecs/parallel_query.rs) | Illustrates parallel queries with `ParallelIterator` diff --git a/examples/ecs/generic_system.rs b/examples/ecs/generic_system.rs index eb513868d1896..9893bfafa409d 100644 --- a/examples/ecs/generic_system.rs +++ b/examples/ecs/generic_system.rs @@ -20,6 +20,7 @@ fn main() { .add_system_set(SystemSet::on_update(AppState::MainMenu).with_system(transition_to_in_game)) // add the cleanup systems .add_system_set( + // Pass in the types your system should operate on using the :: (turbofish) syntax SystemSet::on_exit(AppState::MainMenu).with_system(cleanup_system::), ) .add_system_set( @@ -58,6 +59,8 @@ fn transition_to_in_game(mut state: ResMut>, keyboard_input: Res } } +// Type arguments on functions come after the function name, but before ordinary arguments. +// Here, the `Component` trait is a trait bound on T, our generic type fn cleanup_system(mut commands: Commands, query: Query>) { for e in query.iter() { commands.entity(e).despawn_recursive();