分辨率小于1080*1920的背景统一放大1.2倍

dev_chengFeng
gaoxin 2020-09-05 20:05:50 +08:00
parent 06afe99236
commit f9350d662f
1 changed files with 14 additions and 3 deletions

View File

@ -20,9 +20,20 @@ public class UIBgAdaptive : MonoBehaviour
bgList[i].GetComponent<RectTransform>().pivot = new Vector2(0.5f, 0.5f);
bgList[i].transform.localScale = new Vector3(1, 1, 1);
bgList[i].transform.localPosition = new Vector3(0, 0, 0);
float curWidth = (1080f / 1920f) * Screen.height;
//Debug.Log("Screen.height " + Screen.height+ " curWidth "+ curWidth);
bgList[i].GetComponent<RectTransform>().sizeDelta = new Vector2(curWidth, Screen.height);
//float curHeight = 1920 * (Screen.height / Screen.width) / (1920 / 1080);
//float curWidth = (1080f / 1920f) * curHeight;
//bgList[i].GetComponent<RectTransform>().sizeDelta = new Vector2(curWidth, curHeight);
if (Screen.height > 1920)
{
float curWidth = (1080f / 1920f) * Screen.height;
//Debug.Log("Screen.height " + Screen.height+ " curWidth "+ curWidth);
bgList[i].GetComponent<RectTransform>().sizeDelta = new Vector2(curWidth, Screen.height);
}
else
{
bgList[i].GetComponent<RectTransform>().sizeDelta = new Vector2(1080, 1920) * 1.2f;
}
}
}
}