Howdy, I'm trying to make a clickable text2d but haven't had success in getting the observer to trigger. Unfortunately Google hasn't been too helpful and that AI overview has been even worse. I've tried with and without Pickable as well.
fn on_click_options(_: On<Pointer<Click>>, mut next_menu_state: ResMut<NextState<MainMenuState>>) {
warn!("Click called");
next_menu_state.set(MainMenuState::Options) ;
}
fn options_button(commands: &mut Commands, window: &Single<&Window>) {
let (x, y) = options_button_position(window);
commands.spawn((
Name::new("Options button"),
MainMenuButton::Options,
Transform::from_translation(Vec3::new(x, y, 0.0)),
Text2d::new("Options"),
TextFont {
font_size: 42.0,
..Default::default()
},
Pickable::default(),
)).observe(on_click_options);
}