Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion examples/gizmos/transform_gizmo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use bevy::{
camera_controller::free_camera::{FreeCamera, FreeCameraPlugin},
gizmos::transform_gizmo::{
TransformGizmoCamera, TransformGizmoFocus, TransformGizmoMode, TransformGizmoPlugin,
TransformGizmoSettings, TransformGizmoSpace,
TransformGizmoSettings, TransformGizmoSpace, TransformGizmoState,
},
picking::{pointer::PointerButton, Pickable},
prelude::*,
Expand Down Expand Up @@ -123,10 +123,18 @@ fn on_click_select(
click: On<Pointer<Click>>,
mut commands: Commands,
existing: Query<Entity, With<TransformGizmoFocus>>,
gizmo_state: Res<TransformGizmoState>,
) {
if click.button != PointerButton::Primary {
return;
}
// `Pointer<Click>` runs in PreUpdate; gizmo `active` is set in PostUpdate, so on the press frame
// `active` is still false while the user is grabbing an axis (`hovered_axis` is set). Mesh
// picking often resolves to geometry behind the axis and would steal `TransformGizmoFocus`
// before the drag starts.
if gizmo_state.active || gizmo_state.hovered_axis.is_some() {
return;
}
// Remove focus from all entities
for e in &existing {
commands.entity(e).remove::<TransformGizmoFocus>();
Expand Down
Loading