use std::time::Duration; use bevy::{color::palettes::basic::*, prelude::*, window::WindowResolution, winit::WinitPlugin}; use bevy_wayland::{prelude::*, ExternalEventDispatcher}; const NORMAL_BUTTON: Color = Color::srgb(0.15, 0.15, 0.15); const HOVERED_BUTTON: Color = Color::srgb(0.25, 0.25, 0.25); const PRESSED_BUTTON: Color = Color::srgb(0.35, 0.75, 0.35); fn main() { App::new() .add_plugins(( DefaultPlugins .build() .disable::() .set(WindowPlugin { primary_window: Some(Window { resolution: WindowResolution::new(400.0, 400.0), present_mode: bevy::window::PresentMode::AutoVsync, ..Default::default() }), ..Default::default() }), WaylandPlugin, )) .add_systems(Startup, (setup, external_tick_sender)) .add_systems(Update, (button_system, exit_on_esc)) .run(); } fn external_tick_sender(external_event_dispatcher: Res) { let displatcher = external_event_dispatcher.clone(); let mut count = 5; std::thread::spawn(move || loop { println!("Spawned Thread"); std::thread::sleep(Duration::from_secs(1)); displatcher.dispatch().unwrap(); count -= 1; if count < 0 { return; } }); } #[allow(clippy::type_complexity)] fn button_system( mut interaction_query: Query< ( &Interaction, &mut BackgroundColor, &mut BorderColor, &Children, ), (Changed, With