diff --git a/Assets/MediaPipeUnity/Samples/UI/Scripts/AutoFit.cs b/Assets/MediaPipeUnity/Samples/UI/Scripts/AutoFit.cs index 3a74f77cf..78e708e45 100644 --- a/Assets/MediaPipeUnity/Samples/UI/Scripts/AutoFit.cs +++ b/Assets/MediaPipeUnity/Samples/UI/Scripts/AutoFit.cs @@ -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);