diff --git a/examples/3d/anisotropy.rs b/examples/3d/anisotropy.rs index edb0e92539..e8134d2ad1 100644 --- a/examples/3d/anisotropy.rs +++ b/examples/3d/anisotropy.rs @@ -81,13 +81,7 @@ impl Display for Scene { fn main() { App::new() .init_resource::() - .add_plugins(DefaultPlugins.set(WindowPlugin { - primary_window: Some(Window { - title: "Bevy Anisotropy Example".into(), - ..default() - }), - ..default() - })) + .add_plugins(DefaultPlugins) .add_systems(Startup, setup) .add_systems(Update, create_material_variants) .add_systems(Update, animate_light) diff --git a/examples/3d/clustered_decals.rs b/examples/3d/clustered_decals.rs index 60a445b483..299c743897 100644 --- a/examples/3d/clustered_decals.rs +++ b/examples/3d/clustered_decals.rs @@ -122,13 +122,7 @@ impl MaterialExtension for CustomDecalExtension { /// Entry point. fn main() { App::new() - .add_plugins(DefaultPlugins.set(WindowPlugin { - primary_window: Some(Window { - title: "Bevy Clustered Decals Example".into(), - ..default() - }), - ..default() - })) + .add_plugins(DefaultPlugin) .add_plugins(MaterialPlugin::< ExtendedMaterial, >::default()) diff --git a/examples/3d/light_textures.rs b/examples/3d/light_textures.rs index babaa9b8a8..fa6e89860b 100644 --- a/examples/3d/light_textures.rs +++ b/examples/3d/light_textures.rs @@ -105,13 +105,7 @@ struct HelpText; /// Entry point. fn main() { App::new() - .add_plugins(DefaultPlugins.set(WindowPlugin { - primary_window: Some(Window { - title: "Bevy Light Textures Example".into(), - ..default() - }), - ..default() - })) + .add_plugins(DefaultPlugins) .init_resource::() .add_event::>() .add_event::>() diff --git a/examples/3d/mixed_lighting.rs b/examples/3d/mixed_lighting.rs index ffff8652b4..0a66e1c2b9 100644 --- a/examples/3d/mixed_lighting.rs +++ b/examples/3d/mixed_lighting.rs @@ -116,13 +116,7 @@ const INITIAL_SPHERE_POSITION: Vec3 = vec3(0.0, 0.5233223, 0.0); fn main() { App::new() - .add_plugins(DefaultPlugins.set(WindowPlugin { - primary_window: Some(Window { - title: "Bevy Mixed Lighting Example".into(), - ..default() - }), - ..default() - })) + .add_plugins(DefaultPlugins) .add_plugins(MeshPickingPlugin) .insert_resource(AmbientLight { color: ClearColor::default().0, diff --git a/examples/3d/pcss.rs b/examples/3d/pcss.rs index b2715f0b57..32d919c7bc 100644 --- a/examples/3d/pcss.rs +++ b/examples/3d/pcss.rs @@ -113,13 +113,7 @@ enum AppSetting { fn main() { App::new() .init_resource::() - .add_plugins(DefaultPlugins.set(WindowPlugin { - primary_window: Some(Window { - title: "Bevy Percentage Closer Soft Shadows Example".into(), - ..default() - }), - ..default() - })) + .add_plugins(DefaultPlugins) .add_event::>() .add_systems(Startup, setup) .add_systems(Update, widgets::handle_ui_interactions::) diff --git a/examples/3d/specular_tint.rs b/examples/3d/specular_tint.rs index 148f11ba5c..0b657d7ef3 100644 --- a/examples/3d/specular_tint.rs +++ b/examples/3d/specular_tint.rs @@ -50,13 +50,7 @@ enum TintType { /// The entry point. fn main() { App::new() - .add_plugins(DefaultPlugins.set(WindowPlugin { - primary_window: Some(Window { - title: "Bevy Specular Tint Example".into(), - ..default() - }), - ..default() - })) + .add_plugins(DefaultPlugins) .init_resource::() .init_resource::() .insert_resource(AmbientLight { diff --git a/examples/mobile/src/lib.rs b/examples/mobile/src/lib.rs index de83152552..8fa419e5d0 100644 --- a/examples/mobile/src/lib.rs +++ b/examples/mobile/src/lib.rs @@ -15,35 +15,16 @@ use bevy::{ /// `main.rs`. pub fn main() { let mut app = App::new(); - app.add_plugins( - DefaultPlugins - .set(LogPlugin { - // This will show some log events from Bevy to the native logger. - level: Level::DEBUG, - filter: "wgpu=error,bevy_render=info,bevy_ecs=trace".to_string(), - ..Default::default() - }) - .set(WindowPlugin { - primary_window: Some(Window { - resizable: false, - mode: WindowMode::BorderlessFullscreen(MonitorSelection::Primary), - // on iOS, gestures must be enabled. - // This doesn't work on Android - recognize_rotation_gesture: true, - // Only has an effect on iOS - prefers_home_indicator_hidden: true, - // Only has an effect on iOS - prefers_status_bar_hidden: true, - // Only has an effect on iOS - preferred_screen_edges_deferring_system_gestures: ScreenEdge::Bottom, - ..default() - }), - ..default() - }), - ) + app.add_plugins(DefaultPlugins.set(LogPlugin { + // This will show some log events from Bevy to the native logger. + level: Level::DEBUG, + filter: "wgpu=error,bevy_render=info,bevy_ecs=trace".to_string(), + ..Default::default() + })) // Make the winit loop wait more aggressively when no user input is received // This can help reduce cpu usage on mobile devices .insert_resource(WinitSettings::mobile()) + .add_observer(configure_window) .add_systems(Startup, (setup_scene, setup_music)) .add_systems( Update, @@ -58,6 +39,22 @@ pub fn main() { .run(); } +fn configure_window(trigger: On, mut window: Query<&mut Window>) { + let mut window = window.get_mut(trigger.target()).unwrap(); + + window.resizable = false; + window.mode = WindowMode::BorderlessFullscreen(MonitorSelection::Primary); + // on iOS, gestures must be enabled. + // This doesn't work on Android + window.recognize_rotation_gesture = true; + // Only has an effect on iOS + window.prefers_home_indicator_hidden = true; + // Only has an effect on iOS + window.prefers_status_bar_hidden = true; + // Only has an effect on iOS + window.preferred_screen_edges_deferring_system_gestures = ScreenEdge::Bottom; +} + fn touch_camera( window: Query<&Window>, mut touches: EventReader,