Skip to content

Commit

Permalink
fix: proper autofit image if camera is rotated (#1043)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dender46 authored Nov 3, 2023
1 parent 01cdd56 commit 2d2863e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Assets/MediaPipeUnity/Samples/UI/Scripts/AutoFit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ private void LateUpdate()
var center = rect.center;
var topLeftRel = new Vector2(rect.xMin - center.x, rect.yMin - center.y);
var topRightRel = new Vector2(rect.xMax - center.x, rect.yMin - center.y);
var rotatedTopLeftRel = rectTransform.rotation * topLeftRel;
var rotatedTopRightRel = rectTransform.rotation * topRightRel;
var rotatedTopLeftRel = rectTransform.localRotation * topLeftRel;
var rotatedTopRightRel = rectTransform.localRotation * topRightRel;
var wMax = Mathf.Max(Mathf.Abs(rotatedTopLeftRel.x), Mathf.Abs(rotatedTopRightRel.x));
var hMax = Mathf.Max(Mathf.Abs(rotatedTopLeftRel.y), Mathf.Abs(rotatedTopRightRel.y));
return (2 * wMax, 2 * hMax);
Expand Down

0 comments on commit 2d2863e

Please sign in to comment.