Unity UGUI 的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);

posted @ 2017-08-25 17:06  AaronBlogs  阅读(2146)  评论(0编辑  收藏  举报