//! An example demonstrating how to translate, rotate and scale UI elements. use bevy::color::palettes::css::DARK_GRAY; use bevy::color::palettes::css::RED; use bevy::color::palettes::css::YELLOW; use bevy::picking::hover::Hovered; use bevy::platform::collections::HashSet; use bevy::prelude::*; use bevy::ui::Pressed; use bevy::ui_widgets::Button; use core::f32::consts::FRAC_PI_8; fn main() { App::new() .add_plugins(DefaultPlugins) .add_systems(Startup, setup) .add_systems(Update, button_system) .add_systems(Update, translation_system) .run(); } const NORMAL_BUTTON: Color = Color::WHITE; const HOVERED_BUTTON: Color = Color::Srgba(YELLOW); const PRESSED_BUTTON: Color = Color::Srgba(RED); /// A button that rotates the target node #[derive(Component)] pub struct RotateButton(pub Rot2); /// A button that scales the target node #[derive(Component)] pub struct ScaleButton(pub f32); /// Marker component so the systems know which entities to translate, rotate and scale #[derive(Component)] pub struct TargetNode; /// Handles button interactions fn button_system( mut button_query: Query< ( Entity, &mut BackgroundColor, Ref, Option>, Option<&RotateButton>, Option<&ScaleButton>, ), With