Skip to content
Snippets Groups Projects
Commit 135e513e authored by Gino Valente's avatar Gino Valente
Browse files

Fix WindowSize not updating

parent db7042dd
No related branches found
No related tags found
No related merge requests found
......@@ -27,6 +27,8 @@ pub struct WindowSize(pub f32, pub f32);
fn update_window_size(
mut window_resized_events: EventReader<WindowResized>,
mut window_created_events: EventReader<WindowCreated>,
windows: Res<Windows>,
mut window_size: ResMut<WindowSize>,
) {
let mut changed_window_ids = Vec::new();
// handle resize events. latest events are handled first because we only want to resize each
......@@ -48,6 +50,14 @@ fn update_window_size(
changed_window_ids.push(event.id);
}
for window_id in changed_window_ids {
if let Some(window) = windows.get(window_id) {
let width = window.width();
let height = window.height();
*window_size = WindowSize(width, height);
}
}
}
#[derive(Debug, Clone, Copy, Default)]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment