From 2d2863ea740a6a5ad01854ea88ab5f48be2a36b6 Mon Sep 17 00:00:00 2001 From: Dmytro Bahandov Date: Fri, 3 Nov 2023 04:59:27 +0200 Subject: [PATCH] fix: proper autofit image if camera is rotated (#1043) --- Assets/MediaPipeUnity/Samples/UI/Scripts/AutoFit.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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);