Skip to content

Instantly share code, notes, and snippets.

@ChristopherBiscardi
Created August 16, 2024 04:55
Show Gist options
  • Save ChristopherBiscardi/09a4048e7388a462f14c7edc882e24a1 to your computer and use it in GitHub Desktop.
Save ChristopherBiscardi/09a4048e7388a462f14c7edc882e24a1 to your computer and use it in GitHub Desktop.
all events get read
use bevy::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(
Update,
(
produce,
read_one.run_if(on_event::<MyEvent>()),
read_two,
)
.chain(),
)
.add_event::<MyEvent>()
.run();
}
#[derive(Event, Debug)]
struct MyEvent;
fn produce(mut writer: EventWriter<MyEvent>) {
writer.send(MyEvent);
info!("\n\n");
}
fn read_one(mut reader: EventReader<MyEvent>) {
info!("read one");
for e in reader.read() {
info!("event 1");
}
}
fn read_two(mut reader: EventReader<MyEvent>) {
info!("read two");
for event in reader.read() {
info!("event 2");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment