forked from bevyengine/bevy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
return_after_run.rs
37 lines (34 loc) · 1.34 KB
/
return_after_run.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//! Shows how to return to the calling function after a windowed Bevy app has exited.
//!
//! In windowed *Bevy* applications, executing code below a call to `App::run()` is
//! not recommended because `App::run()` might never return.
//!
//! This example demonstrates the use of `WinitSettings::return_from_run` to
//! require that `App::run()` *does* return but this is not recommended. Be sure
//! to read the documentation on both `App::run()` and `WinitSettings::return_from_run`
//! for caveats and further details:
//!
//! - <https://docs.rs/bevy/latest/bevy/app/struct.App.html#method.run>
//! - <https://docs.rs/bevy/latest/bevy/winit/struct.WinitSettings.html#structfield.return_from_run>
use bevy::{prelude::*, window::WindowPlugin, winit::WinitSettings};
fn main() {
println!("Running Bevy App");
App::new()
.insert_resource(WinitSettings {
return_from_run: true,
..default()
})
.add_plugins(DefaultPlugins.set(WindowPlugin {
primary_window: Some(Window {
title: "Close the window to return to the main function".into(),
..default()
}),
..default()
}))
.add_system(system)
.run();
println!("Bevy App has exited. We are back in our main function.");
}
fn system() {
info!("Logging from Bevy App");
}