diff options
author | chai <chaifix@163.com> | 2021-05-08 23:15:13 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-05-08 23:15:13 +0800 |
commit | d07e14add74e017b52ab2371efeea1aa4ea10ced (patch) | |
tree | efd07869326e4c428f5bfe43fad0c2583d32a401 /Assets/ThirdParty/Gallery/Utils.cs |
+init
Diffstat (limited to 'Assets/ThirdParty/Gallery/Utils.cs')
-rw-r--r-- | Assets/ThirdParty/Gallery/Utils.cs | 14 |
1 files changed, 14 insertions, 0 deletions
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)); + } +} |