From 22a4c87a5b58caaa06cc81068cd0c4708f6d2cec Mon Sep 17 00:00:00 2001 From: gaoxin Date: Fri, 4 Jun 2021 18:06:44 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E8=83=8C=E6=99=AF=E5=9B=BE=E3=80=91?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=83=8C=E6=99=AF=E5=9B=BE=E7=9A=84=E5=A4=A7?= =?UTF-8?q?=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/UI/UIBgAdaptive.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/UI/UIBgAdaptive.cs b/Assets/Scripts/UI/UIBgAdaptive.cs index 3537f6feb7..976c72d7c5 100644 --- a/Assets/Scripts/UI/UIBgAdaptive.cs +++ b/Assets/Scripts/UI/UIBgAdaptive.cs @@ -26,9 +26,20 @@ public class UIBgAdaptive : MonoBehaviour //bgList[i].GetComponent().sizeDelta = new Vector2(curWidth, curHeight); if (Screen.height >= 1920) { - float curWidth = (1080f / 1920f) * Screen.height; + //--计算比例因子 比例因子 = 10 ^ ((lg(屏幕宽 / 开发宽) + lg(屏幕高 / 开发高) / 2)) + //local log = math.log(Screen.width / 1080, 10) + math.log(Screen.height / 1920, 10) + //local avg = log / 2 + //local ft = math.pow(10, avg) + //-- 实际分辨率 = 屏幕分辨率 / 比例因子 + //UIManager.UIHeight = Screen.height / ft + //UIManager.UIWidth = Screen.width / ft + float log = Mathf.Log10(Screen.width / 1080f) + Mathf.Log10(Screen.height / 1920f); + float avg = log / 2f; + float ft = Mathf.Pow(10, avg); + float curHeight = Screen.height / ft; + float curWidth = curHeight /1920f * 1080f; //Debug.Log("Screen.height " + Screen.height+ " curWidth "+ curWidth); - bgList[i].GetComponent().sizeDelta = new Vector2(curWidth, Screen.height); + bgList[i].GetComponent().sizeDelta = new Vector2(curWidth, curHeight); } else {