From d07e14add74e017b52ab2371efeea1aa4ea10ced Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 8 May 2021 23:15:13 +0800 Subject: +init --- Assets/ThirdParty/Gallery/Utils.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Assets/ThirdParty/Gallery/Utils.cs (limited to 'Assets/ThirdParty/Gallery/Utils.cs') diff --git a/Assets/ThirdParty/Gallery/Utils.cs b/Assets/ThirdParty/Gallery/Utils.cs new file mode 100644 index 0000000..29c9962 --- /dev/null +++ b/Assets/ThirdParty/Gallery/Utils.cs @@ -0,0 +1,14 @@ +using UnityEngine; +using System.Collections; + +public static class Utils{ + + public static void setSize(RectTransform rect, float width, float height) + { + Vector2 newSize = new Vector2(width, height); + Vector2 oldSize = rect.rect.size; + Vector2 deltaSize = newSize - oldSize; + rect.offsetMin = rect.offsetMin - new Vector2(deltaSize.x * rect.pivot.x, deltaSize.y * rect.pivot.y); + rect.offsetMax = rect.offsetMax + new Vector2(deltaSize.x * (1f - rect.pivot.x), deltaSize.y * (1f - rect.pivot.y)); + } +} -- cgit v1.1-26-g67d0