//! A stress test for picking and events with many interactive elements. use bevy::{ diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin}, prelude::*, window::{PresentMode, WindowPlugin}, }; use bevy_mod_picking::prelude::*; const ROW_COLUMN_COUNT: usize = 110; const FONT_SIZE: f32 = 7.0; /// This example shows what happens when there is a lot of buttons on screen. fn main() { let mut app = App::new(); app.add_plugins(( DefaultPlugins.set(WindowPlugin { primary_window: Some(Window { present_mode: PresentMode::AutoNoVsync, ..default() }), ..default() }), FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin::default(), )) .add_plugins( DefaultPickingPlugins .build() .disable::(), ) .insert_resource(DebugPickingMode::Normal) .add_systems(Startup, setup) .add_systems(Update, update_button_colors); if std::env::args().any(|arg| arg == "recompute-layout") { app.add_systems(Update, |mut ui_scale: ResMut| { ui_scale.set_changed(); }); } if std::env::args().any(|arg| arg == "recompute-text") { app.add_systems(Update, |mut text_query: Query<&mut Text>| { text_query .iter_mut() .for_each(|mut text| text.set_changed()); }); } app.run(); } #[derive(Component)] struct IdleColor(Color); #[allow(clippy::type_complexity)] /// Use the [`PickingInteraction`] state of each button to update its color. fn update_button_colors( mut buttons: Query< (Option<&PickingInteraction>, &mut UiImage, &IdleColor), (With