//! This example is identical to the minimal example, except a cube has been added that when clicked //! on, won't deselect anything else you have selected. use bevy::prelude::*; use bevy_mod_picking::prelude::*; fn main() { App::new() .add_plugins(DefaultPlugins.set(low_latency_window_plugin())) .add_plugins(DefaultPickingPlugins) .insert_resource(DebugPickingMode::Normal) .add_systems(Startup, setup) .run(); } fn setup( mut commands: Commands, mut meshes: ResMut>, mut materials: ResMut>, ) { // cube with NoDeselect commands .spawn(( PbrBundle { mesh: meshes.add(Cuboid::default()), material: materials.add(Color::srgb(0.8, 0.7, 0.6)), transform: Transform::from_xyz(1.5, 0.5, 0.0), ..default() }, PickableBundle::default(), NoDeselect, // <- When this entity is clicked, other entities won't be deselected. )) .remove::(); // <- Removing this removes the entity's ability to be selected. commands.spawn(( PbrBundle { mesh: meshes.add(Cuboid::default()), material: materials.add(Color::srgb(0.8, 0.7, 0.6)), transform: Transform::from_xyz(0.0, 0.5, 0.0), ..default() }, PickableBundle::default(), )); commands.spawn(PointLightBundle { transform: Transform::from_xyz(4.0, 8.0, 4.0), point_light: PointLight { shadows_enabled: true, ..default() }, ..default() }); commands.spawn((Camera3dBundle { transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y), ..default() },)); }