use bevy::prelude::*; use bevy_mod_gizmos::*; #[rustfmt::skip] fn main() { App::new() .add_plugins(DefaultPlugins) .add_plugin(GizmosPlugin) .add_startup_system(setup) .add_system(update) // This resource is used to showcase being able // to run any system on hover and click .init_resource::() .run(); } #[derive(Resource, Default)] struct GizmosOffset(Vec3); fn setup(mut commands: Commands) { println!("Trying hovering and clicking the center gizmo"); let cam_transform = Transform::from_xyz(0.0, 0.0, 8.0); commands.spawn(( Camera3dBundle { transform: cam_transform.looking_at(Vec3::ZERO, Vec3::Y), ..Default::default() }, GizmoInteractionCamera, )); } // Notice this resource is read only, // it is being mutated by the hover and click systems fn update(offset: Res) { draw_gizmo( Gizmo::new(Vec3::ZERO + offset.0, 1.0, Color::WHITE) .on_click(|| println!("I've been clicked!")) .on_hover(|| println!("Hovered")) .on_hover_system(|mut offset: ResMut, time: Res