We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Any ideas why this isn't working?
use bevy::prelude::*; use bevy::text::Text2dBounds; use bevy_mod_picking::prelude::*; pub fn run () { App::new() .add_plugins(DefaultPlugins) .add_plugins(DefaultPickingPlugins) .add_systems(Startup, setup) .run(); } #[derive(Component)] struct ClickableText; fn setup(mut commands: Commands, asset_server: Res<AssetServer>) { // Camera commands.spawn(Camera2dBundle::default()); let font = asset_server.load("fonts/OpenSans-Regular.ttf"); let text_style = TextStyle { font, font_size: 30.0, color: Color::WHITE, }; commands.spawn(( Text2dBundle { text: Text::from_section( "Click me!", text_style, ), text_2d_bounds: Text2dBounds { size: Vec2::new(300.0, 100.0), }, transform: Transform::from_xyz(0.0, 0.0, 0.0), ..default() }, PickableBundle::default(), On::<Pointer<Click>>::run(on_click), ClickableText, )); } fn on_click( event: Listener<Pointer<Click>>, query: Query<&Text, With<ClickableText>> ) { println!("Not firing"); if let Ok(text) = query.get(event.target) { println!("Clicked text: {}", text.sections[0].value); } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Any ideas why this isn't working?
The text was updated successfully, but these errors were encountered: