Skip to content

Commit

Permalink
Make UI scale to window width so it remains the same size
Browse files Browse the repository at this point in the history
  • Loading branch information
haihala committed Dec 26, 2023
1 parent b159262 commit b0a3fb8
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion client/lib/src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,23 @@ impl Plugin for UIPlugin {
round_text::setup_round_info_text,
shop::setup_shop,
),
);
)
.add_systems(Update, set_ui_scale);
}
}

fn set_ui_scale(
windows: Query<&Window>,
mut ui_scale: ResMut<UiScale>,
mut local_width: Local<f32>,
) {
let window = windows.single();

if window.width() == *local_width {
return;
}

dbg!(&window.resolution);
ui_scale.0 = (window.width() / 1920.0) as f64;
*local_width = window.width();
}

0 comments on commit b0a3fb8

Please sign in to comment.