If there is a OnEnter(State) or OnExit(State) system, inside of which I despawn entities with OutlineBundle, it would always crash with the following message:
thread 'main' panicked at src/pipeline.rs:337:49:
called `Result::unwrap()` on an `Err` value: NoSuchEntity(Entity { index: 2, generation: 1 })
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Encountered a panic in system `bevy_render::batching::no_gpu_preprocessing::batch_and_prepare_sorted_render_phase<bevy_mod_outline::node::StencilOutline, bevy_mod_outline::pipeline::OutlinePipeline>`!
I tried both OnEnter and OnExit, but I'm not sure if other non-update schedulers does that ? And for the record, doing the same steps without ever inserting outlines works well.
If there is a
OnEnter(State)
orOnExit(State)
system, inside of which I despawn entities withOutlineBundle
, it would always crash with the following message:I tried both
OnEnter
andOnExit
, but I'm not sure if other non-update schedulers does that ? And for the record, doing the same steps without ever inserting outlines works well.Repro
This seems to be enough to reproduce the issue, a diff for [`examples/pieces.rs`](https://github.com/komadori/bevy_mod_outline/blob/master/examples/pieces.rs): ```diff --- a/examples/pieces.rs +++ b/examples/pieces.rs @@ -10,11 +10,20 @@ fn main() { .insert_resource(Msaa::Sample4) .insert_resource(ClearColor(Color::BLACK)) .add_plugins((DefaultPlugins, OutlinePlugin)) - .add_systems(Startup, setup) - .add_systems(Update, rotates) + .add_systems(OnEnter(AppState::Scene), setup) + .add_systems(OnExit(AppState::Scene), teardown) + .add_systems(Update, (rotates, change_state)) + .init_state::