Skip to content

Commit

Permalink
made world code into exclusive system
Browse files Browse the repository at this point in the history
  • Loading branch information
Trashtalk217 committed Oct 19, 2023
1 parent 966978c commit 0dff8fe
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions content/news/2023-10-21-bevy-0.12/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ fn increment(mut counter: ResMut<Counter>) {
println!("{}", counter.0);
}

let mut world = World::new();
world.init_resource::<Counter>();
let id = world.register_system(increment);
let _ = world.run_system(id); // prints 1
let _ = world.run_system(id); // prints 2
fn foo(world: &mut World) {
world.init_resource::<Counter>();
let id = world.register_system(increment);
let _ = world.run_system(id); // prints 1
let _ = world.run_system(id); // prints 2
}
```

There are three simple steps to using one-shot systems: register a system, store its `SystemId`, and then use either exclusive world access or commands to run the corresponding system.
Expand Down

0 comments on commit 0dff8fe

Please sign in to comment.