You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An exclusive system adds Res<MyResource> at the start of CoreStage::Update, and then an exclusive system removes it at the end of the stage.
input_system changes MyState to MyState::Two when you click the left mouse button.
using_system runs in CoreStage::Update when MyState::Two is entered, and has Res<MyResource> as an argument.
Run the following code and left click.
use bevy::prelude::*;fnmain(){App::new().add_plugins(DefaultPlugins).add_state_to_stage(CoreStage::Update,MyState::One).add_system_set_to_stage(CoreStage::Update,SystemSet::new().with_system(inserting_system.exclusive_system().at_start()).with_system(removing_system.exclusive_system().at_end()).with_system(input_system).with_system(using_system.with_run_criteria(State::on_enter(MyState::Two))),).run();}#[derive(Clone,Eq,PartialEq,Debug,Hash)]enumMyState{One,Two,}structMyResource;fninserting_system(world:&mutWorld){
world.insert_resource(MyResource);}fnremoving_system(world:&mutWorld){
world.remove_resource::<MyResource>();}fninput_system(i_mouse_button:Res<Input<MouseButton>>,mutmy_state:ResMut<State<MyState>>){if i_mouse_button.just_pressed(MouseButton::Left){
my_state.set(MyState::Two);}}fnusing_system(_my_resource:Res<MyResource>){}
What you expected to happen
No crash, because the exclusive system that removes the Res<MyResource> is set to run at the end of the stage, which should be after state transitions.
What actually happened
Crash because it can't find the Res<MyResource>.
More info
Workaround: Insert it at the beginning of the next stage instead of at the end of this one.
The text was updated successfully, but these errors were encountered:
Bevy version
0.6.1
Operating system & version
Ubuntu 20.04.3 LTS
What you did
Res<MyResource>
at the start ofCoreStage::Update
, and then an exclusive system removes it at the end of the stage.input_system
changesMyState
toMyState::Two
when you click the left mouse button.using_system
runs inCoreStage::Update
whenMyState::Two
is entered, and hasRes<MyResource>
as an argument.Run the following code and left click.
What you expected to happen
No crash, because the exclusive system that removes the
Res<MyResource>
is set to run at the end of the stage, which should be after state transitions.What actually happened
Crash because it can't find the
Res<MyResource>
.More info
Workaround: Insert it at the beginning of the next stage instead of at the end of this one.
The text was updated successfully, but these errors were encountered: