Fix drag and swipe speed to not respect scale factor#292
Conversation
Revert part of #256
There was a problem hiding this comment.
Pull request overview
Updates uGUI drag-and-drop and swipe operators so drag/swipe motion timing no longer changes with the parent Canvas scale factor, keeping interaction duration consistent across different resolutions.
Changes:
- Remove Canvas
scaleFactoradjustments from swipe speed and distance calculations. - Remove Canvas
scaleFactoradjustments from drag-and-drop speed. - Update copyright headers to 2026.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| Runtime/Operators/UguiSwipeOperator.cs | Removes Canvas scale-factor-based scaling for swipe destination distance and DragAsync speed. |
| Runtime/Operators/UguiDragAndDropOperator.cs | Removes Canvas scale-factor-based scaling for DragAsync speed. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| using (var simulator = new PointerDragEventSimulator(gameObject, raycastResult, Logger)) | ||
| { | ||
| simulator.BeginDrag(); | ||
| await simulator.DragAsync(destination, scaledSpeed, cancellationToken); | ||
| await simulator.DragAsync(destination, _swipeSpeed, cancellationToken); | ||
| simulator.EndDrag(out _, out _); |
There was a problem hiding this comment.
Behavior change (removing Canvas scale-factor adjustments for swipe speed/distance) isn’t covered by tests that exercise non-default Canvas scale factors. Please add/update tests to validate swipe duration/step size remains consistent when the Canvas scale factor differs (e.g., via CanvasScaler).
| using (var simulator = new PointerDragEventSimulator(gameObject, raycastResult, Logger)) | ||
| { | ||
| simulator.BeginDrag(); | ||
| await simulator.DragAsync(destination, scaledSpeed, cancellationToken); | ||
| await simulator.DragAsync(destination, _dragSpeed, cancellationToken); | ||
|
|
There was a problem hiding this comment.
Behavior change (drag speed no longer scaled by Canvas scale factor) isn’t covered by tests that use a non-default Canvas scale factor. Please add/update a test that configures the Canvas scale factor (e.g., via CanvasScaler) and asserts the drag duration/step size is unaffected.
Code Metrics Report
Details | | master (9f29b44) | #292 (e2d48f0) | +/- |
|--------------------|------------------|----------------|------|
+ | Code to Test Ratio | 1:1.3 | 1:1.3 | +0.0 |
| Code | 4628 | 4621 | -7 |
| Test | 6186 | 6186 | 0 |Reported by octocov |
Before
Drag and swipe speed respects the scale factor.
refs #256
After
Drag and swipe speed NOT respects the scale factor.
Because the duration should be constant regardless of resolution.