use bevy::{ diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin}, input::mouse::{MouseButtonInput, MouseWheel}, prelude::*, }; use bevy_iced::iced::{ self, widget::{slider, text, text_input, Button, Column, Row}, Alignment, Style, }; use bevy_iced::{IcedContext, IcedPlugin, IcedSettings}; use rand::random as rng; #[derive(Clone, Event)] enum UiMessage { BoxRequested, Scale(f32), Text(String), } #[derive(Resource, Deref, DerefMut)] pub struct UiActive(bool); #[derive(Resource)] pub struct UiData { scale: f32, text: String, } pub fn main() { App::new() .add_plugins(DefaultPlugins.set(WindowPlugin { primary_window: Some(Window { present_mode: bevy_window::PresentMode::AutoNoVsync, ..Default::default() }), ..Default::default() })) .add_plugins(( IcedPlugin::default(), FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin::default(), )) .add_event::() .insert_resource(UiActive(true)) .insert_resource(UiData { scale: 50.0, text: "Welcome to Iced!".to_owned(), }) .insert_resource(IcedSettings { scale_factor: None, theme: iced::Theme::Light, style: Style { text_color: iced::Color::from_rgb(0.0, 1.0, 1.0), }, }) .add_systems(Startup, build_program) .add_systems( Update, (tick, box_system, update_scale_factor, toggle_ui, ui_system), ) .run(); } fn build_program(mut commands: Commands) { commands.spawn(Camera2dBundle::default()); } fn tick(mut sprites: Query<&mut Sprite>, time: Res