From 3049d8f0da3398e714fbfe665d7a12902e074255 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Tue, 30 Jan 2024 15:49:40 +0100 Subject: [PATCH] Fix example send_and_receive_events (#11615) # Objective - Example `send_and_receive_events` added in #11574 panics ``` thread 'Compute Task Pool (3)' panicked at bevy/crates/bevy_ecs/src/system/system_param.rs:570:17: Resource requested by send_and_receive_events::read_and_write_different_event_types does not exist: bevy_ecs::event::Events Encountered a panic in system `send_and_receive_events::read_and_write_different_event_types`! Encountered a panic in system `bevy_app::main_schedule::Main::run_main`! ``` ## Solution - Register the events used in the system - Don't use logger as it's not setup with `MinimalPlugins`, just print --------- Co-authored-by: Alice Cecile Co-authored-by: Kanabenki --- examples/ecs/send_and_receive_events.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/ecs/send_and_receive_events.rs b/examples/ecs/send_and_receive_events.rs index b186937f029ee..cd2d8c4af3a5d 100644 --- a/examples/ecs/send_and_receive_events.rs +++ b/examples/ecs/send_and_receive_events.rs @@ -27,6 +27,8 @@ fn main() { let mut app = App::new(); app.add_plugins(MinimalPlugins) .add_event::() + .add_event::() + .add_event::() .add_systems(Update, read_and_write_different_event_types) .add_systems( Update, @@ -71,7 +73,7 @@ struct DebugEvent { /// A system that sends all combinations of events. fn send_events(mut events: EventWriter, frame_count: Res) { - info!("Sending events for frame {:?}", *frame_count); + println!("Sending events for frame {:?}", frame_count.0); events.send(DebugEvent { resend_from_param_set: false, @@ -109,7 +111,7 @@ fn send_and_receive_param_set( mut param_set: ParamSet<(EventReader, EventWriter)>, frame_count: Res, ) { - info!( + println!( "Sending and receiving events for frame {} with a `ParamSet`", frame_count.0 ); @@ -140,7 +142,7 @@ fn send_and_receive_manual_event_reader( mut events: ResMut>, frame_count: Res, ) { - info!( + println!( "Sending and receiving events for frame {} with a `Local", frame_count.0 );