1. 程式人生 > >小功能丨RectTransform的控制方式

小功能丨RectTransform的控制方式

控制RectTransform的方式

#region RectTransform
//1.改變RectTransform的top
//GetComponent<RectTransform>().offsetMax = new Vector2(GetComponent<RectTransform>().offsetMax.x, top);
//2.改變RectTransform的bottom
//GetComponent<RectTransform>().offsetMin = new Vector2(GetComponent<RectTransform>().offsetMin.x, bottom);
//3.改變RectTransform的width,height
//GetComponent<RectTransform>().sizeDelta = new Vector2(width, height);
//4.改變RectTransform的pos
//GetComponent<RectTransform>().anchoredPosition3D = new Vector3(posx, posy, posz);
//GetComponent<RectTransform>().anchoredPosition = new Vector2(posx, posy);
#endregion