mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 12:43:34 +00:00
Fix panic in examples using argh on the web (#11513)
# Objective Fixes #11503 ## Solution Use an empty set of args on the web. ## Discussion Maybe in the future we could wrap this so that we can use query args on the web or something, but this was the minimum changeset I could think of to keep the functionality and make them not panic on the web.
This commit is contained in:
parent
143066de63
commit
bcbab18f37
5 changed files with 22 additions and 0 deletions
|
@ -94,7 +94,11 @@ impl FromStr for Mode {
|
||||||
const FIXED_TIMESTEP: f32 = 0.2;
|
const FIXED_TIMESTEP: f32 = 0.2;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
// `from_env` panics on the web
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
let args: Args = argh::from_env();
|
let args: Args = argh::from_env();
|
||||||
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
let args = Args::from_args(&[], &[]).unwrap();
|
||||||
|
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins((
|
.add_plugins((
|
||||||
|
|
|
@ -42,7 +42,12 @@ struct Args {
|
||||||
|
|
||||||
/// This example shows what happens when there is a lot of buttons on screen.
|
/// This example shows what happens when there is a lot of buttons on screen.
|
||||||
fn main() {
|
fn main() {
|
||||||
|
// `from_env` panics on the web
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
let args: Args = argh::from_env();
|
let args: Args = argh::from_env();
|
||||||
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
let args = Args::from_args(&[], &[]).unwrap();
|
||||||
|
|
||||||
let mut app = App::new();
|
let mut app = App::new();
|
||||||
|
|
||||||
app.add_plugins((
|
app.add_plugins((
|
||||||
|
|
|
@ -66,7 +66,11 @@ impl FromStr for Layout {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
// `from_env` panics on the web
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
let args: Args = argh::from_env();
|
let args: Args = argh::from_env();
|
||||||
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
let args = Args::from_args(&[], &[]).unwrap();
|
||||||
|
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins((
|
.add_plugins((
|
||||||
|
|
|
@ -33,7 +33,11 @@ struct Foxes {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
// `from_env` panics on the web
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
let args: Args = argh::from_env();
|
let args: Args = argh::from_env();
|
||||||
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
let args = Args::from_args(&[], &[]).unwrap();
|
||||||
|
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins((
|
.add_plugins((
|
||||||
|
|
|
@ -19,7 +19,12 @@ struct Args {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
// `from_env` panics on the web
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
let args: Args = argh::from_env();
|
let args: Args = argh::from_env();
|
||||||
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
let args = Args::from_args(&[], &[]).unwrap();
|
||||||
|
|
||||||
let window = if let Some(scale_factor) = args.scale_factor {
|
let window = if let Some(scale_factor) = args.scale_factor {
|
||||||
Window {
|
Window {
|
||||||
resolution: WindowResolution::default().with_scale_factor_override(scale_factor),
|
resolution: WindowResolution::default().with_scale_factor_override(scale_factor),
|
||||||
|
|
Loading…
Reference in a new issue