mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 12:43:34 +00:00
Fix minimising
example minimizing every frame (#15850)
# Objective The `minimising` example is a bit annoying to run locally, because it attempts to minimize the window every frame, so un-minimizing it is difficult. ## Solution Only minimize once. The contents of the example can now be inspected, and the window easily closed after the minimization happens. ## Testing `cargo run --example minimising` I tested on macos only. --------- Co-authored-by: François Mockers <francois.mockers@vleue.com>
This commit is contained in:
parent
9cfb4a187f
commit
7f24c27645
1 changed files with 7 additions and 7 deletions
|
@ -1,6 +1,6 @@
|
||||||
//! A test to confirm that `bevy` allows minimising the window
|
//! A test to confirm that `bevy` allows minimising the window
|
||||||
//! This is run in CI to ensure that this doesn't regress again.
|
//! This is run in CI to ensure that this doesn't regress again.
|
||||||
use bevy::prelude::*;
|
use bevy::{core::FrameCount, prelude::*};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// TODO: Combine this with `resizing` once multiple_windows is simpler than
|
// TODO: Combine this with `resizing` once multiple_windows is simpler than
|
||||||
|
@ -18,13 +18,13 @@ fn main() {
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn minimise_automatically(mut windows: Query<&mut Window>, mut frames: Local<u32>) {
|
fn minimise_automatically(mut windows: Query<&mut Window>, frames: Res<FrameCount>) {
|
||||||
if *frames == 60 {
|
if frames.0 != 60 {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let mut window = windows.single_mut();
|
let mut window = windows.single_mut();
|
||||||
window.set_minimized(true);
|
window.set_minimized(true);
|
||||||
} else {
|
|
||||||
*frames += 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A simple 3d scene, taken from the `3d_scene` example
|
/// A simple 3d scene, taken from the `3d_scene` example
|
||||||
|
|
Loading…
Reference in a new issue