-
-
Notifications
You must be signed in to change notification settings - Fork 2
Fix drag and swipe speed to not respect scale factor #292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| // Copyright (c) 2023-2025 Koji Hasegawa. | ||
| // Copyright (c) 2023-2026 Koji Hasegawa. | ||
| // This software is released under the MIT License. | ||
|
|
||
| using System; | ||
|
|
@@ -179,24 +179,19 @@ public async UniTask OperateAsync(GameObject gameObject, Vector2 direction, | |
| raycastResult = RaycastResultExtensions.CreateFrom(gameObject, GetScreenPoint); | ||
| } | ||
|
|
||
| var canvas = gameObject.GetComponentInParent<Canvas>(); | ||
| var scaleFactor = canvas != null ? canvas.scaleFactor : 1f; | ||
| var scaledDistance = _swipeDistance * scaleFactor; | ||
| var scaledSpeed = (int)(_swipeSpeed * scaleFactor); | ||
|
|
||
| // Log direction and distance | ||
| var operationLogger = new OperationLogger(gameObject, this, Logger, ScreenshotOptions); | ||
| operationLogger.Properties.Add("position", raycastResult.screenPosition); | ||
| operationLogger.Properties.Add("direction", direction); | ||
| await operationLogger.Log(); | ||
|
|
||
| var normalizedDirection = direction.normalized; | ||
| var destination = raycastResult.screenPosition + normalizedDirection * scaledDistance; | ||
| var destination = raycastResult.screenPosition + normalizedDirection * _swipeDistance; | ||
|
|
||
nowsprinting marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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 _); | ||
|
Comment on lines
191
to
195
|
||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.