From 5ca88372febc0ebab5cbdb5f922c59a646b8fb94 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期四, 12 六月 2025 17:43:34 +0800
Subject: [PATCH] 18 子 2D卡牌客户端搭建 / 2D卡牌客户端搭建

---
 Main/System/UIBase/UIBase.cs      |   68 ++++++++--------------
 Main/System/UIBase/OneLevelWin.cs |   29 ++++++---
 Main/Manager/UIManager.cs         |   29 ++++++++-
 Main/System/Main/MainWin.cs       |   16 ----
 4 files changed, 70 insertions(+), 72 deletions(-)

diff --git a/Main/Manager/UIManager.cs b/Main/Manager/UIManager.cs
index 6ef3fd8..21187f3 100644
--- a/Main/Manager/UIManager.cs
+++ b/Main/Manager/UIManager.cs
@@ -225,6 +225,26 @@
         return null;
     }
 
+    public UIBase GetUI(string uiName)
+    {
+        if (string.IsNullOrEmpty(uiName))
+        {
+            // 璁板綍閿欒鏃ュ織
+            Debug.LogError("UI鍚嶇О涓虹┖");
+            return null;
+        }
+
+        // 灏濊瘯浠庡瓧鍏镐腑鑾峰彇UI瀹炰緥鍒楄〃
+        if (uiDict.TryGetValue(uiName, out List<UIBase> uiList) && uiList.Count > 0)
+        {
+            // 杩斿洖绗竴涓疄渚�
+            return uiList[0];
+        }
+
+        // 濡傛灉涓嶅瓨鍦紝杩斿洖null
+        return null;
+    }
+
     public List<T> GetUIList<T>() where T : UIBase
     {
         List<T> uiList = new List<T>();
@@ -583,14 +603,12 @@
         return target;
     }
 
-    public UIBase OpenWindow(string uiName)
+    public UIBase OpenWindow(string uiName, int functionOrder = 0)
     {
         // 浼樺厛浠巆losedUIDict涓幏鍙�
         UIBase parentUI = null;
 
         UIBase returnValue = null;
-
-        Debug.Log("OpenWindow " + uiName);
 
         List<UIBase> closedUIList = new List<UIBase>();
 
@@ -664,6 +682,7 @@
         UpdateUISortingOrder();
         
         // 鎵撳紑UI
+        returnValue.functionOrder = functionOrder;
         returnValue.HandleOpen();
 
         OnOpenWindow?.Invoke(returnValue);
@@ -677,11 +696,11 @@
     /// <summary>
     /// 鎵撳紑UI
     /// </summary>
-    public T OpenWindow<T>() where T : UIBase
+    public T OpenWindow<T>(int functionOrder = 0) where T : UIBase
     {
         // 鑾峰彇UI绫诲瀷鍚嶇О
         string uiName = typeof(T).Name;
-        return OpenWindow(uiName) as T;
+        return OpenWindow(uiName, functionOrder) as T;
     }
     
     /// <summary>
diff --git a/Main/System/Main/MainWin.cs b/Main/System/Main/MainWin.cs
index 262f519..dc8fd7f 100644
--- a/Main/System/Main/MainWin.cs
+++ b/Main/System/Main/MainWin.cs
@@ -8,10 +8,10 @@
 /// </summary>
 public class MainWin : UIBase
 {
-    private GameObject windowBackground;
+    public GameObject windowBackground;
 
     // 搴曢儴鎸夐挳缁�
-    private Button[] bottomTabButtons;
+    public Button[] bottomTabButtons;
 
     private GameObject[] bottomTabEffects;
     
@@ -27,18 +27,6 @@
     protected override void InitComponent()
     {
         base.InitComponent();
-
-        windowBackground = _rectTransform.Find("RawImgBackground").gameObject;
-
-        bottomTabButtons = new Button[5];
-        for (int i = 1; i <= 5; i++)
-        {
-            string buttonName = "Buttons/Button" + i;
-            bottomTabButtons[i-1] = _rectTransform.Find(buttonName).GetComponent<Button>();
-            #if UNITY_EDITOR
-            //娴嬭瘯浠g爜
-            #endif
-        }
 
         // 鍒濆鍖朥I缁勪欢浜嬩欢
         InitButtonEvents();
diff --git a/Main/System/UIBase/OneLevelWin.cs b/Main/System/UIBase/OneLevelWin.cs
index 04dd726..2326bbb 100644
--- a/Main/System/UIBase/OneLevelWin.cs
+++ b/Main/System/UIBase/OneLevelWin.cs
@@ -29,20 +29,29 @@
     {
         base.InitComponent();
 
-        m_TitleIcon = this.GetComponent<Image>("Pivot/Container_BackGround/Img_Title");
-        m_Group = this.GetComponent<FunctionButtonGroup>("Pivot/Container_Functions");
-        m_Left = this.GetComponent<Button>("Pivot/Container_Buttons/Btn_Left");
-        m_Right = this.GetComponent<Button>("Pivot/Container_Buttons/Btn_Right");
-        m_Close = this.GetComponent<Button>("Pivot/Container_Buttons/Btn_Close");
 
-        m_Copper = this.GetComponent<Text>("Pivot/Container_BackGround/FollowStoreBottom/SilverCountBG/CountText");
+        // //  璺熷師鐗堢殑宸埆 
+        Transform trans = transform;
+
+        // if (_rectTransform != null)
+        // {
+        //     trans = _rectTransform;
+        // }
+
+        m_TitleIcon = trans.GetComponent<Image>("Pivot/Container_BackGround/Img_Title");
+        m_Group = trans.GetComponent<FunctionButtonGroup>("Pivot/Container_Functions");
+        m_Left = trans.GetComponent<Button>("Pivot/Container_Buttons/Btn_Left");
+        m_Right = trans.GetComponent<Button>("Pivot/Container_Buttons/Btn_Right");
+        m_Close = trans.GetComponent<Button>("Pivot/Container_Buttons/Btn_Close");
+
+        m_Copper = trans.GetComponent<Text>("Pivot/Container_BackGround/FollowStoreBottom/SilverCountBG/CountText");
         if (m_Copper != null)
-            m_Diamond = this.GetComponent<Text>("Pivot/Container_BackGround/FollowStoreBottom/GoldCountBG/CountText");
-            m_BindDiamond = this.GetComponent<Text>("Pivot/Container_BackGround/FollowStoreBottom/GoldPaperCountBG/CountText");
+            m_Diamond = trans.GetComponent<Text>("Pivot/Container_BackGround/FollowStoreBottom/GoldCountBG/CountText");
+            m_BindDiamond = trans.GetComponent<Text>("Pivot/Container_BackGround/FollowStoreBottom/GoldPaperCountBG/CountText");
 
-        m_SubWindowContainer = this.GetComponent<RectTransform>("Pivot/Container_SubWindow");
+        m_SubWindowContainer = trans.GetComponent<RectTransform>("Pivot/Container_SubWindow");
 
-        var name = this.gameObject.name;
+        var name = gameObject.name;
         var infos = WindowConfig.GetWindowFunctionInfos(name);
         foreach (var info in infos)
         {
diff --git a/Main/System/UIBase/UIBase.cs b/Main/System/UIBase/UIBase.cs
index 4002e55..b13d522 100644
--- a/Main/System/UIBase/UIBase.cs
+++ b/Main/System/UIBase/UIBase.cs
@@ -24,7 +24,9 @@
     SlideFromTop, // 浠庨《閮ㄦ粦鍏�
     SlideFromBottom, // 浠庡簳閮ㄦ粦鍏�
     SlideFromLeft, // 浠庡乏渚ф粦鍏�
-    SlideFromRight // 浠庡彸渚ф粦鍏�
+    SlideFromRight, // 浠庡彸渚ф粦鍏�
+    ScaleOverInOut,// 缂╂斁锛堣秴杩囷級涔嬪悗鍐嶈繑鍥�
+
 }
 
 [RequireComponent(typeof(Canvas))]
@@ -47,6 +49,8 @@
     // 鍔ㄧ敾鐩稿叧
     [SerializeField] public UIAnimationType openAnimationType = UIAnimationType.None;
     [SerializeField] public UIAnimationType closeAnimationType = UIAnimationType.None;
+    [SerializeField] protected RectTransform _rectTransform; //鐣岄潰榛樿娣诲姞鏍硅妭鐐圭敤浜庤〃鐜扮晫闈㈠紑鍚叧闂姩鐢�
+    
     [SerializeField]/*[HideInInspector]*/ public float animeDuration = 0.2f;
     [SerializeField][HideInInspector] public Ease animationEase = Ease.OutQuad; // 纭繚浣跨敤 DG.Tweening.Ease
 
@@ -69,7 +73,13 @@
 
     private Button btnClickEmptyClose;
 
-    protected int functionOrder = 0;
+    //  璺烵neLevelWin鑱斿姩 瀹為檯涓婃槸闇�瑕佺户鎵胯嚜OneLevelWin鎵嶈兘鐢熸晥鐨勫�� 浣跨敤闇�瑕佹敞鎰�
+    int m_FunctionOrder = 0;
+    public int functionOrder
+    {
+        get { return m_FunctionOrder; }
+        set { m_FunctionOrder = value; }
+    }
 
     // 鍐呴儴鐘舵��
     protected bool isActive = false;
@@ -79,7 +89,6 @@
     // 缁勪欢寮曠敤
     protected Canvas canvas;
     protected CanvasGroup canvasGroup;
-    protected RectTransform _rectTransform; //鐣岄潰榛樿娣诲姞鏍硅妭鐐圭敤浜庤〃鐜扮晫闈㈠紑鍚叧闂姩鐢�
 
     // 鍔ㄧ敾鐩稿叧
     protected Vector3 originalPosition;
@@ -93,7 +102,6 @@
 
     protected virtual void Awake()
     {
-        CreateRootNode();
         //  闃叉鏈変汉涓嶅啓base.InitComponent寮曞彂閿欒 鎵�浠ユ媶鍒�
         InitComponentInternal();
         // 鍦ˋwake涓繘琛屽熀鏈垵濮嬪寲
@@ -116,42 +124,13 @@
         }
     }
 
-    private void CreateRootNode()
-    {
-        if (openAnimationType == UIAnimationType.None && closeAnimationType == UIAnimationType.None)
-            return;
-
-        List<Transform> children = new List<Transform>();
-        foreach (Transform child in transform)
-        {
-            children.Add(child);
-        }
-
-        rootNode = new GameObject("WindowRoot");
-        rootNode.transform.SetParent(transform, false);
-        rootNode.layer = LayerMask.NameToLayer("UI");
-        _rectTransform = rootNode.AddMissingComponent<RectTransform>();
-
-        //璁剧疆鎴愭媺浼告晥鏋滐紝鍜岀埗瀹瑰櫒淇濇寔鍚屾牱澶у皬鑷姩閫傞厤
-        _rectTransform.anchorMin = Vector2.zero;
-        _rectTransform.anchorMax = Vector2.one;
-        _rectTransform.pivot = new Vector2(0.5f, 0.5f);
-        _rectTransform.anchoredPosition = Vector2.zero;
-        _rectTransform.sizeDelta = Vector2.zero; // 璁剧疆涓�0锛岃〃绀烘媺浼稿埌鐖跺鍣ㄥぇ灏�
-
-        foreach (Transform child in children)
-        {
-            child.SetParent(rootNode.transform, false);
-        }
-    }
-
     protected virtual void Start()
     {
         // 瀛愮被鍙互閲嶅啓姝ゆ柟娉曡繘琛岄澶栧垵濮嬪寲
     }
 
     protected async UniTask ApplySettings()
-    {
+    {
         if (clickEmptySpaceClose)
         {
             //寤惰繜鍒涘缓浼氬鑷村眰绾у湪ScreenMask涔嬩笂
@@ -159,9 +138,9 @@
             btnClickEmptyClose = goBtnESC.GetComponent<Button>();
             btnClickEmptyClose.AddListener(CloseWindow);
             btnClickEmptyClose.transform.SetAsFirstSibling();
-            await UniTask.DelayFrame(5);
-
-            btnClickEmptyClose = goBtnESC.GetComponent<Button>();
+            await UniTask.DelayFrame(5);
+
+            btnClickEmptyClose = goBtnESC.GetComponent<Button>();
             btnClickEmptyClose.AddListener(CloseWindow);
         }
     }
@@ -259,6 +238,13 @@
         PlayOpenAnimation();
 
         OnOpen();
+
+        ExecuteNextFrame(NextFrameAfterOpen);
+    }
+
+    protected virtual void NextFrameAfterOpen()
+    {
+
     }
 
     // 鍏抽棴UI - 淇敼鍚庣殑鏂规硶
@@ -279,7 +265,6 @@
         // 绂佺敤浜や簰浣嗕繚鎸佸彲瑙�
         if (canvasGroup != null)
         {
-            canvasGroup.interactable = false;
             canvasGroup.blocksRaycasts = false;
         }
 
@@ -528,7 +513,6 @@
                 if (canvasGroup != null)
                 {
                     canvasGroup.alpha = 0f;
-                    canvasGroup.interactable = false;
                     canvasGroup.blocksRaycasts = false;
                 }
                 if (canvasScaler != null)
@@ -541,7 +525,6 @@
                 if (canvasGroup != null)
                 {
                     canvasGroup.alpha = 1f;
-                    canvasGroup.interactable = false;
                     canvasGroup.blocksRaycasts = false;
                 }
                 if (canvasScaler != null)
@@ -634,11 +617,12 @@
                 // 鍚敤浜や簰
                 if (canvasGroup != null)
                 {
-                    canvasGroup.interactable = true;
                     canvasGroup.blocksRaycasts = true;
                 }
 
             });
+
+            // currentAnimation.ingoreTimeScale = true;
 
             currentAnimation.Play();
         }
@@ -650,7 +634,6 @@
             if (canvasGroup != null)
             {
                 canvasGroup.alpha = 1f;
-                canvasGroup.interactable = true;
                 canvasGroup.blocksRaycasts = true;
             }
             isAnimating = false;
@@ -667,7 +650,6 @@
         if (canvasGroup != null)
         {
             canvasGroup.alpha = 1f;
-            canvasGroup.interactable = true;
             canvasGroup.blocksRaycasts = true;
         }
         if (canvasScaler != null)

--
Gitblit v1.8.0