Created
August 16, 2024 04:55
-
-
Save ChristopherBiscardi/09a4048e7388a462f14c7edc882e24a1 to your computer and use it in GitHub Desktop.
all events get read
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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