From f99dd641fb1eb7ba7cbeab5b763d26a7324315c7 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期二, 24 六月 2025 17:46:37 +0800
Subject: [PATCH] 0312 界面适配

---
 Main/System/UIBase/UIBase.cs |    3 +
 Main/Utility/Constants.cs    |    2 
 Main/Utility/SafeAreaUI.cs   |   65 --------------------------------
 3 files changed, 5 insertions(+), 65 deletions(-)

diff --git a/Main/System/UIBase/UIBase.cs b/Main/System/UIBase/UIBase.cs
index 0e12e51..38b211d 100644
--- a/Main/System/UIBase/UIBase.cs
+++ b/Main/System/UIBase/UIBase.cs
@@ -195,6 +195,9 @@
         }
 
         canvasScaler = GetComponent<CanvasScaler>();
+        canvasScaler.referenceResolution = Constants.DESIGN_RESOLUTION;
+        canvasScaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize;
+        canvasScaler.matchWidthOrHeight = 0;
     }
 
     // 鑾峰彇蹇呰鐨勭粍浠�
diff --git a/Main/Utility/Constants.cs b/Main/Utility/Constants.cs
index 4a51e20..b4e0e74 100644
--- a/Main/Utility/Constants.cs
+++ b/Main/Utility/Constants.cs
@@ -41,7 +41,7 @@
     public const ulong ExpPointValue = 100000000;
 
     public static readonly Vector3 Special_Hide_Position = new Vector3(10000, -10000, 10000);
-    public readonly static Vector2 DESIGN_RESOLUTION = new Vector2(1334, 750);
+    public readonly static Vector2 DESIGN_RESOLUTION = new Vector2(750, 1334);
 
     public static int UnUsedRes_Unload_Delay = 300;
 
diff --git a/Main/Utility/SafeAreaUI.cs b/Main/Utility/SafeAreaUI.cs
index 8f1c476..b58325f 100644
--- a/Main/Utility/SafeAreaUI.cs
+++ b/Main/Utility/SafeAreaUI.cs
@@ -8,21 +8,8 @@
     public const int SafeWidth = 75;
     public const int SafeBottom = 15;   //绔栧睆涓嬫柟闂撮殧
 
-    public enum SimDevice { None, IphoneX }
-    public static SimDevice Sim
-    {
-        set { LocalSave.SetInt("SimDevice", (int)value); }
-        get { return (SimDevice)LocalSave.GetInt("SimDevice"); }
-    }
-
-    Rect[] NSA_IphoneX = new Rect[]
-    {
-        new Rect (0f, 102f / 2436f, 1f, 2202f / 2436f),  // Portrait
-        new Rect (132f / 2436f, 63f / 1125f, 2172f / 2436f, 1062f / 1125f)  // Landscape
-    };
 
     RectTransform _Panel;
-    Rect LastSafeArea = new Rect(0, 0, 0, 0);
     Rect LastRect = new Rect(0, 0, 0, 0);
 
     RectTransform Panel
@@ -47,8 +34,6 @@
 
     void Refresh()
     {
-        // Rect safeArea = GetSafeArea();
-        // if (safeArea != LastSafeArea || LastRect != Panel.rect)
         if (LastRect != Panel.rect)
             ApplySafeArea();
     }
@@ -88,53 +73,5 @@
         }
         LastRect = Panel.rect;
     }
-    #region 绯荤粺api鐨勫畨鍏ㄥ尯
-    Rect GetSafeArea()
-    {
-        if (!Application.isEditor)
-            return Screen.safeArea;
-
-        Rect safeArea = Screen.safeArea;
-
-        if (Sim != SimDevice.None)
-        {
-            Rect nsa = new Rect(0, 0, Screen.width, Screen.height);
-
-            switch (Sim)
-            {
-                case SimDevice.IphoneX:
-                    if (Screen.height > Screen.width)  // Portrait
-                        nsa = NSA_IphoneX[0];
-                    else  // Landscape
-                        nsa = NSA_IphoneX[1];
-                    break;
-                default:
-                    break;
-            }
-
-            safeArea = new Rect(Screen.width * nsa.x, Screen.height * nsa.y, Screen.width * nsa.width, Screen.height * nsa.height);
-        }
-        return safeArea;
-
-    }
-
-    void ApplySafeArea(Rect safeArea)
-    {
-        Debug.LogFormat("ApplySafeArea锛歿0} ; rect:{1}", safeArea, Panel.rect);
-
-        Panel.anchorMin = Vector2.zero;
-        Panel.anchorMax = Vector2.one;
-
-        //閫傞厤鍥涗釜鏂瑰悜
-        // Panel.offsetMin = safeArea.min;
-        // Panel.offsetMax = new Vector2(-(Screen.width - safeArea.max.x), -(Screen.height - safeArea.max.y));
-
-        //鍙�傞厤涓よ竟
-        Panel.offsetMin = new Vector2(safeArea.min.x, 0);
-        Panel.offsetMax = new Vector2(-(Screen.width - safeArea.max.x), 0);
-
-        LastRect = Panel.rect;
-        LastSafeArea = safeArea;
-    }
-    #endregion 
+    
 }
\ No newline at end of file

--
Gitblit v1.8.0