generated from tipragot/rust
Renaming WindowSize #77
|
@ -12,21 +12,21 @@ impl Plugin for ResponsiveScalingPlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The default window size.
|
/// The default ui window size.
|
||||||
#[derive(Resource)]
|
#[derive(Resource)]
|
||||||
pub struct WindowSize(pub Vec2);
|
pub struct UIWindowSize(pub Vec2);
|
||||||
|
|
||||||
/// Initializes the window size.
|
/// Initializes [UIWindowSize].
|
||||||
pub fn init_window_size(mut command: Commands) {
|
pub fn init_window_size(mut command: Commands) {
|
||||||
command.insert_resource(WindowSize(Vec2::new(1280., 720.)));
|
command.insert_resource(UIWindowSize(Vec2::new(1280., 720.)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Calculates the ui_scale.0 depending on the default screen size
|
/// Calculates the ui_scale.0 depending on the [UIWindowSize]
|
||||||
/// in order to make the screen responsive.
|
/// in order to make the screen responsive.
|
||||||
pub fn change_scaling(
|
pub fn change_scaling(
|
||||||
mut ui_scale: ResMut<UiScale>,
|
mut ui_scale: ResMut<UiScale>,
|
||||||
windows: Query<&Window>,
|
windows: Query<&Window>,
|
||||||
size: Res<WindowSize>,
|
size: Res<UIWindowSize>,
|
||||||
) {
|
) {
|
||||||
let window = windows.get_single().expect("Main window not found");
|
let window = windows.get_single().expect("Main window not found");
|
||||||
let (a, b) = (
|
let (a, b) = (
|
||||||
|
|
Loading…
Reference in a new issue