use bevy::input::mouse::MouseMotion; use games::*; fn main() { App::new() .init_resource::() .add_plugins(BaseGamePlugin { camera: CameraType::Camera3d }) .add_systems(Startup, init_ui) .add_systems(Update, ( sync_resource_to_ui::.run_if(resource_changed::), update_foo.run_if(on_event::) )) .run(); } #[derive(Resource, Debug, Default)] struct Thing(u8); impl Display for Thing { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "{}", self.0) } } fn init_ui( mut commands: Commands ) { commands.spawn(( Node { align_self: AlignSelf::Start, justify_self: JustifySelf::Center, ..default() }, Text("Displays a sync'd resource tracking the number of mouse events (mod 256)".into()), )); commands.spawn((Node { align_self: AlignSelf::Center, justify_self: JustifySelf::Center, ..default() }, Text("Placeholder".into()), SyncResource::::default())); } fn update_foo( mut events: EventReader, mut thing: ResMut, ) { events.read().for_each(|_| { thing.0 = thing.0.overflowing_add(1).0; }); }