Migrate more examples

This commit is contained in:
Jan Hohenheim 2025-07-07 22:16:54 +02:00
parent b65ef4da1b
commit 74b6a118b5
No known key found for this signature in database
7 changed files with 29 additions and 68 deletions

View File

@ -81,13 +81,7 @@ impl Display for Scene {
fn main() {
App::new()
.init_resource::<AppStatus>()
.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)

View File

@ -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<StandardMaterial, CustomDecalExtension>,
>::default())

View File

@ -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::<AppStatus>()
.add_event::<WidgetClickEvent<Selection>>()
.add_event::<WidgetClickEvent<Visibility>>()

View File

@ -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,

View File

@ -113,13 +113,7 @@ enum AppSetting {
fn main() {
App::new()
.init_resource::<AppStatus>()
.add_plugins(DefaultPlugins.set(WindowPlugin {
primary_window: Some(Window {
title: "Bevy Percentage Closer Soft Shadows Example".into(),
..default()
}),
..default()
}))
.add_plugins(DefaultPlugins)
.add_event::<WidgetClickEvent<AppSetting>>()
.add_systems(Startup, setup)
.add_systems(Update, widgets::handle_ui_interactions::<AppSetting>)

View File

@ -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::<AppAssets>()
.init_resource::<AppStatus>()
.insert_resource(AmbientLight {

View File

@ -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<Add, PrimaryWindow>, 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<TouchInput>,