//改变RectTransform的top
GetComponent<RectTransform>().offsetMax = new Vector2(GetComponent<RectTransform>().offsetMax.x, top);
//改变RectTransform的bottom
GetComponent<RectTransform>().offsetMin = new Vector2(GetComponent<RectTransform>().offsetMin.x, bottom);
//改变RectTransform的width,height
GetComponent<RectTransform>().sizeDelta = new Vector2(width, height);
//改变RectTransform的pos
GetComponent<RectTransform>().anchoredPosition3D = new Vector3(posx,posy,posz);
GetComponent<RectTransform>().anchoredPosition = new Vector2(posx,posy);
Unity UI大小动态设置(Resize Unity UI RectTransform)
最新推荐文章于 2023-09-13 19:13:36 发布