I want to add an icon next to the mouse to remind you what tool you're using. it obviously should stick to the mouse like glue or else it would look weird.
I wrote this system:
fn mouse_icon(
window: Query<&Window, With<bevy::window::PrimaryWindow>>,
mut icon: Query<(&mut Style, &mut Visibility), With<MouseIconMarker>>,
) {
let mut icon = icon.single_mut();
let window = window.single();
let Some(position) = window.cursor_position() else {
return;
};
icon.0.left = Val::Px(position.x);
icon.0.bottom = Val::Px(window.height() - position.y);
// *icon.1 = Visibility::Visible;
info!("mouse icon at {:?} {:?}", icon.0.left, icon.0.top);
}
it works as intended, but the icon lags one frame behind the mouse. Is there some alternate way of reading the mouse, or an alternate way of drawing the icon, or what?