-
Hi, I have a problem with getting fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Update, on_window_resized)
.run();
}
fn on_window_resized(events: EventReader<WindowResized>) {
for _ in events.read() {
info!("window resized!");
}
} but with fn main() {
App::new()
.add_plugins(DefaultPlugins)
.observe(on_window_resized)
.run();
}
fn on_window_resized(_: Trigger<WindowResized>) {
info!("window resized!");
} I'm learning bevy so surely I have made a mistake, but I can't find what it is. Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Buffered events (using I believe there are some plans to further unify buffered events and observers in some way, and to make the API slightly clearer / less footgunny, but I don't remember details of what it'll look like. Also see |
Beta Was this translation helpful? Give feedback.
Buffered events (using
EventReader
/EventWriter
) are currently treated separately from observer events. Somy_event_writer.send(event)
adds buffered events that can only be read by anEventReader
, not observers.WindowResized
is a buffered event like this, and can not be listened to by observers.I believe there are some plans to further unify buffered events and observers in some way, and to make the API slightly clearer / less footgunny, but I don't remember details of what it'll look like.
Also see
Observer
docs: https://docs.rs/bevy_ecs/latest/bevy_ecs/observer/struct.Observer.html