在動態(tài)加載頁面時 不免要對RectTransform進(jìn)行設(shè)置 以下是獲得RectTransform屬性并設(shè)置的方法
1.改變RectTransform的top
GetComponent().offsetMax = new Vector2(GetComponent().offsetMax.x, top);
2.改變RectTransform的bottom
GetComponent().offsetMin = new Vector2(GetComponent().offsetMin.x, bottom);
3.改變RectTransform的width盆顾,height
GetComponent().sizeDelta = new Vector2(width, height);
4.改變RectTransfrom的PosX PosY PosZ
gameobject.GetComponent<RectTransfrom>().anchoredPosition3D = new Vector3(0, 0, 0);
gameobject.GetComponent<RectTransfrom>().anchoredPosition=new Vector2(0,0);
告誡自己:知足常樂,以夢為馬,浪跡天涯