diff --git a/Source/Editor/Gizmo/ViewportRubberBandSelector.cs b/Source/Editor/Gizmo/ViewportRubberBandSelector.cs index 542e8b388..66e835fac 100644 --- a/Source/Editor/Gizmo/ViewportRubberBandSelector.cs +++ b/Source/Editor/Gizmo/ViewportRubberBandSelector.cs @@ -36,11 +36,12 @@ public sealed class ViewportRubberBandSelector /// Triggers the start of a rubber band selection. /// /// True if selection started, otherwise false. - public bool TryStartingRubberBandSelection() + public bool TryStartingRubberBandSelection(Float2 mousePosition) { if (!_isRubberBandSpanning && _owner.Gizmos.Active != null && !_owner.Gizmos.Active.IsControllingMouse && !_owner.IsRightMouseButtonDown) { _tryStartRubberBand = true; + _cachedStartingMousePosition = mousePosition; return true; } return false; @@ -82,12 +83,15 @@ public sealed class ViewportRubberBandSelector return; } - if (_tryStartRubberBand && (Mathf.Abs(_owner.MouseDelta.X) > 0.1f || Mathf.Abs(_owner.MouseDelta.Y) > 0.1f) && canStart) + if (_tryStartRubberBand && canStart) { - _isRubberBandSpanning = true; - _cachedStartingMousePosition = mousePosition; - _rubberBandRect = new Rectangle(_cachedStartingMousePosition, Float2.Zero); - _tryStartRubberBand = false; + var delta = mousePosition - _cachedStartingMousePosition; + if (Mathf.Abs(delta.X) > 0.1f || Mathf.Abs(delta.Y) > 0.1f) + { + _isRubberBandSpanning = true; + _rubberBandRect = new Rectangle(_cachedStartingMousePosition, Float2.Zero); + _tryStartRubberBand = false; + } } else if (_isRubberBandSpanning && _owner.Gizmos.Active != null && !_owner.Gizmos.Active.IsControllingMouse && !_owner.IsRightMouseButtonDown) { diff --git a/Source/Editor/Viewport/MainEditorGizmoViewport.cs b/Source/Editor/Viewport/MainEditorGizmoViewport.cs index 5343a1fe5..d25a8ab80 100644 --- a/Source/Editor/Viewport/MainEditorGizmoViewport.cs +++ b/Source/Editor/Viewport/MainEditorGizmoViewport.cs @@ -620,7 +620,7 @@ namespace FlaxEditor.Viewport { base.OnLeftMouseButtonDown(); - _rubberBandSelector.TryStartingRubberBandSelection(); + _rubberBandSelector.TryStartingRubberBandSelection(_viewMousePos); } ///