Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select event is not dispatched when clicking on child entities #367

Open
SOF3 opened this issue Sep 22, 2024 · 0 comments
Open

Select event is not dispatched when clicking on child entities #367

SOF3 opened this issue Sep 22, 2024 · 0 comments

Comments

@SOF3
Copy link

SOF3 commented Sep 22, 2024

Minimal code to reproduce:

use bevy::prelude::*;
use bevy_mod_picking::prelude::*;

fn main() -> AppExit {
    let mut app = App::new();
    app.add_plugins((
        bevy::DefaultPlugins,
        bevy_mod_picking::DefaultPickingPlugins,
    ));

    app.add_systems(Startup, |mut commands: Commands, mut meshes: ResMut<Assets<Mesh>>, mut materials: ResMut<Assets<StandardMaterial>>| {
        commands.spawn(Camera3dBundle{
            transform: Transform::from_xyz(0.0, 0.0, 5.0),
            ..Default::default()
        });
        commands.spawn((
            SpatialBundle::default(),
            On::<Pointer<Select>>::run(|listener: Listener<Pointer<Select>>| { println!("Select {:?}", listener.listener()) }),
            On::<Pointer<Deselect>>::run(|listener: Listener<Pointer<Deselect>>| { println!("Deselect {:?}", listener.listener()) }),
            On::<Pointer<Click>>::run(|listener: Listener<Pointer<Click>>| { println!("Click {:?}", listener.listener()) }),
            On::<Pointer<Over>>::run(|listener: Listener<Pointer<Over>>| { println!("Over {:?}", listener.listener()) }),
            On::<Pointer<Out>>::run(|listener: Listener<Pointer<Out>>| { println!("Out {:?}", listener.listener()) }),
        )).with_children(|b| {
            b.spawn((
                    PbrBundle {
                        mesh: meshes.add(Cuboid::default()),
                        material: materials.add(StandardMaterial { base_color: Color::WHITE, ..Default::default() }),
                        ..Default::default()
                    },
            ));
        });
    });

    app.run()
}

Outputs when I move cursor onto the cuboid, click, release, move cursor out:

Over Entity { index: 3, generation: 1 }

Click Entity { index: 3, generation: 1 }
Out Entity { index: 3, generation: 1 }

It seems inconsistent that both over/out and click work on child entities but selection does not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant