Skip to content

Commit 2d2863e

Browse files
authored
fix: proper autofit image if camera is rotated (#1043)
1 parent 01cdd56 commit 2d2863e

File tree

1 file changed

+2
-2
lines changed
  • Assets/MediaPipeUnity/Samples/UI/Scripts

1 file changed

+2
-2
lines changed

Assets/MediaPipeUnity/Samples/UI/Scripts/AutoFit.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ private void LateUpdate()
5454
var center = rect.center;
5555
var topLeftRel = new Vector2(rect.xMin - center.x, rect.yMin - center.y);
5656
var topRightRel = new Vector2(rect.xMax - center.x, rect.yMin - center.y);
57-
var rotatedTopLeftRel = rectTransform.rotation * topLeftRel;
58-
var rotatedTopRightRel = rectTransform.rotation * topRightRel;
57+
var rotatedTopLeftRel = rectTransform.localRotation * topLeftRel;
58+
var rotatedTopRightRel = rectTransform.localRotation * topRightRel;
5959
var wMax = Mathf.Max(Mathf.Abs(rotatedTopLeftRel.x), Mathf.Abs(rotatedTopRightRel.x));
6060
var hMax = Mathf.Max(Mathf.Abs(rotatedTopLeftRel.y), Mathf.Abs(rotatedTopRightRel.y));
6161
return (2 * wMax, 2 * hMax);

0 commit comments

Comments
 (0)