blob: 29c996264c1911b4ce63d991f95af55e8bfe67fb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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));
}
}
|