Quitting the App
To cleanly shut down bevy, send an AppExit
event from any system:
use bevy::app::AppExit;
fn exit_system(mut exit: EventWriter<AppExit>) {
exit.send(AppExit);
}
For prototyping, bevy provides a system you can add to your App
,
to close the focused window on pressing the Esc
key. When all windows are
closed, Bevy will quit automatically.
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_system(bevy::window::close_on_esc)
.run();
}