mirror of
https://github.com/bevyengine/bevy
synced 2024-11-26 06:30:19 +00:00
text_wrap_debug
scale factor commandline args (#9951)
# Objective Add commandline arguments to `text_wrap_debug` to set the window and UI scale factors.
This commit is contained in:
parent
20ed3e0e76
commit
418405046a
1 changed files with 29 additions and 1 deletions
|
@ -1,13 +1,41 @@
|
|||
//! This example demonstrates text wrapping and use of the `LineBreakOn` property.
|
||||
|
||||
use argh::FromArgs;
|
||||
use bevy::prelude::*;
|
||||
use bevy::text::BreakLineOn;
|
||||
use bevy::window::WindowResolution;
|
||||
use bevy::winit::WinitSettings;
|
||||
|
||||
#[derive(FromArgs, Resource)]
|
||||
/// `text_wrap_debug` demonstrates text wrapping and use of the `LineBreakOn` property
|
||||
struct Args {
|
||||
#[argh(option)]
|
||||
/// window scale factor
|
||||
scale_factor: Option<f64>,
|
||||
|
||||
#[argh(option, default = "1.")]
|
||||
/// ui scale factor
|
||||
ui_scale: f64,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let args: Args = argh::from_env();
|
||||
let window = if let Some(scale_factor) = args.scale_factor {
|
||||
Window {
|
||||
resolution: WindowResolution::default().with_scale_factor_override(scale_factor),
|
||||
..Default::default()
|
||||
}
|
||||
} else {
|
||||
Window::default()
|
||||
};
|
||||
|
||||
App::new()
|
||||
.add_plugins(DefaultPlugins)
|
||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
||||
primary_window: Some(window),
|
||||
..Default::default()
|
||||
}))
|
||||
.insert_resource(WinitSettings::desktop_app())
|
||||
.insert_resource(UiScale(args.ui_scale))
|
||||
.add_systems(Startup, spawn)
|
||||
.run();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue