use bevy::{color::palettes::css::*, prelude::*}; use bevy_alt_ui_navigation_lite::events::{Direction, NavRequest}; use bevy_alt_ui_navigation_lite::prelude::{ DefaultNavigationPlugins, FocusState, Focusable, NavRequestSystem, }; use bevy_alt_ui_navigation_lite::systems::InputMapping; /// This example shows what happens when there is a lot of focusables on screen. /// It doesn't run well on debug builds, you should try running it with the `--release` /// flag. /// /// It is very useful to assess the performance of bevy ui and how expansive our systems /// are. /// /// You can toggle automatic generation of NavRequest with the `K` key. fn main() { App::new() .add_plugins((DefaultPlugins, DefaultNavigationPlugins)) .add_systems(Startup, setup) .add_systems( Update, ( non_stop_move.before(NavRequestSystem), button_system.after(NavRequestSystem), ), ) .run(); } #[derive(Component)] struct IdleColor(Color); fn button_system( mut interaction_query: Query<(&Focusable, &mut UiImage, &IdleColor), Changed>, ) { for (focusable, mut image, IdleColor(idle_color)) in interaction_query.iter_mut() { if let FocusState::Focused = focusable.state() { image.color = ORANGE_RED.into(); } else { image.color = *idle_color; } } } struct MyDirection(Direction); impl Default for MyDirection { fn default() -> Self { Self(Direction::South) } } fn non_stop_move( input: Res>, mut requests: EventWriter, mut enabled: Local, time: Res