[游戏开发][Unity]UGUI代码设置锚点

//设置左下角锚点
rectTrans.anchorMin = Vector3.zero;
rectTrans.anchorMax = Vector3.zero;


//设置右下角锚点
rectTrans.anchorMin = new Vector2(1, 0);
rectTrans.anchorMax = new Vector2(1, 0);
//设置全屏拉伸
//设置锚点
rectTrans.anchorMin = new Vector2(0,0);
rectTrans.anchorMax = new Vector2(1,1);

//与锚点距离,全部为0
rectTrans.offsetMax = Vector2.zero;
rectTrans.offsetMin = Vector2.zero;

你可能感兴趣的:(开发心得,unity,ui)