屏幕自适应问题:
private void InitUI()//屏幕自适应办法
{
Vector2 editScreen = new Vector2(593, 327);
Transform canvas = GameObject.Find("Canvas").transform;
Vector2 scaleExchange = new Vector2(Screen.width / editScreen.x, Screen.height / editScreen.y);
for(int i = 0;i < canvas.childCount;i++)
{
RectTransform canvasChildRT = canvas.GetChild(i).GetComponent<RectTransform>();
canvasChildRT.position = new Vector3(scaleExchange.x * canvasChildRT.position.x, scaleExchange.y * canvasChildRT.position.y,0);
canvasChildRT.sizeDelta = new Vector3(scaleExchange.x * canvasChildRT.sizeDelta.x, scaleExchange.y * canvasChildRT.sizeDelta.y,1);
}
}