ugui用到了RectTransform,对ugui的操作 很多体现在RectTransform上:
RectTransform rectT = go.GetComponent<RectTransform>();
if (texture.width > texture.height)
{
rectT.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, originalWidth);
rectT.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, texture.height * originalWidth / texture.width);
}
RectTransform rectT = go.GetComponent<RectTransform>();
rectT.offsetMax = new Vector2(-170, tmpY);
RectTransform rectT = txt0.GetComponent<RectTransform>();
Vector3 vec = rectT.localPosition;
rectT.localPosition = new Vector3(vec.x, -70, vec.z);