use bevy::prelude::*; fn main() { App::build() .add_default_plugins() .init_resource::() .add_startup_system(setup.system()) .add_system(button_system.system()) .run(); } struct ButtonMaterials { normal: Handle, hovered: Handle, pressed: Handle, } impl FromResources for ButtonMaterials { fn from_resources(resources: &Resources) -> Self { let mut materials = resources.get_mut::>().unwrap(); ButtonMaterials { normal: materials.add(Color::rgb(0.02, 0.02, 0.02).into()), hovered: materials.add(Color::rgb(0.05, 0.05, 0.05).into()), pressed: materials.add(Color::rgb(0.1, 0.5, 0.1).into()), } } } fn button_system( button_materials: Res, mut click_query: Query<( &Button, Changed, Option<&Hover>, &mut Handle, &Children, )>, mut hover_query: Query<( &Button, Changed, Option<&Click>, &mut Handle, &Children, )>, label_query: Query<&mut Label>, ) { for (_button, hover, click, mut material, children) in &mut hover_query.iter() { let mut label = label_query.get_mut::