From 5f3093f4be480c9d37ea98b41ab7d730ed009208 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期五, 27 六月 2025 15:08:23 +0800
Subject: [PATCH] merge

---
 Main/System/UIBase/UIBase.cs |  145 +++++-------------------------------------------
 1 files changed, 15 insertions(+), 130 deletions(-)

diff --git a/Main/System/UIBase/UIBase.cs b/Main/System/UIBase/UIBase.cs
index 35878f9..e30a84c 100644
--- a/Main/System/UIBase/UIBase.cs
+++ b/Main/System/UIBase/UIBase.cs
@@ -40,7 +40,14 @@
     [SerializeField] public UILayer uiLayer = UILayer.Mid;
     [SerializeField][HideInInspector] public string uiName;
     [SerializeField] public bool isMainUI = false;
-    [SerializeField] public bool supportParentChildRelation = true; // 鏂板锛氭槸鍚︽敮鎸佺埗瀛愬叧绯�
+
+    // 鏂板锛氭槸鍚︽敮鎸佺埗瀛愬叧绯�
+    // 鐖跺瓙鍏崇郴:UI鎷ユ湁鐨勪笂涓嬬骇閾惧紡鍏崇郴
+    // 鍦ㄩ潪鐗瑰畾鎯呭喌涓� 閮借鎷ユ湁鐖跺瓙鍏崇郴 锛堜竴鑸潵璇村姛鑳介兘瑕佹湁鐖跺瓙鍏崇郴 渚嬪鐨勬槸渚嬪绯荤粺寮圭獥 
+    // 涓荤晫闈㈣繖绉嶄笉闇�瑕� 鍦ㄥ埗浣淯I浼�  鐩墠鐨勯渶姹傛槸 鍔熻兘鍏ㄩ儴鍋氬湪Middle灞傦級
+    // 鎷ユ湁鐖跺瓙鍏崇郴 鍦ㄥ叧闂埗鐣岄潰鐨勬椂鍊� 瀛愮晫闈細杩炲悓涓�璧峰叧闂� 瀛愮晫闈㈡墦寮�鏃� 鐖剁晫闈㈢殑鈥滃洖鍚堟暟鈥濅細鍒锋柊 鍥炲悎鏁拌瑙佹寔涔呭寲鐩稿叧鐨勬敞閲�
+    // 
+    [SerializeField] public bool supportParentChildRelation = true; 
 
     // 鎸佷箙鍖栫浉鍏�
     [SerializeField] public bool isPersistent = false;
@@ -329,143 +336,21 @@
     /// <param name="autoDestroy">鏄惁鑷姩閿�姣侊紝榛樿涓簍rue</param>
     /// <param name="destroyDelay">鑷姩閿�姣佸欢杩熸椂闂达紝榛樿涓�5绉�</param>
     /// <returns>鐗规晥娓告垙瀵硅薄</returns>
-    public GameObject PlayUIEffect(int id, Transform parent = null, bool autoDestroy = true, float destroyDelay = 5f)
+    public EffectPlayer PlayUIEffect(int id, Transform parent = null, bool autoDestroy = true, float destroyDelay = 5f)
     {
         // 浣跨敤榛樿鍊�
         if (parent == null) parent = transform;
         
-        EffectConfig effectCfg = EffectConfig.Get(id);
+        EffectPlayer player = parent.gameObject.AddComponent<EffectPlayer>();
 
-        if (null == effectCfg)
-        {
-            return null;
-        }
+        player.effectId = id;
+        player.autoDestroy = autoDestroy;
+        player.destroyDelay = destroyDelay;
+        player.canvas = canvas;
 
-        // 鍔犺浇鐗规晥璧勬簮
-        var effectPrefab = ResManager.Instance.LoadAsset<GameObject>("UIEffect/" + effectCfg.packageName, effectCfg.fxName);
-        if (effectPrefab == null)
-        {
-            Debug.LogError($"鍔犺浇UI鐗规晥澶辫触: {effectCfg.packageName}");
-            return null;
-        }
-        
-        // 瀹炰緥鍖栫壒鏁�
-        GameObject effectObj = Instantiate(effectPrefab, parent);
-        effectObj.name = $"Effect_{effectCfg.packageName}";
-        
-        // 娣诲姞鐗规晥绌块�忛樆鎸″櫒
-        EffectPenetrationBlocker blocker = effectObj.AddComponent<EffectPenetrationBlocker>();
-        blocker.parentCanvas = canvas;
-
-        //  寤惰繜涓�甯ф墠鐢熸晥
-        this.DelayFrame(blocker.UpdateSortingOrder);
-
-        // blocker.UpdateSortingOrder();
-        
-        // 鑷姩閿�姣�
-        if (autoDestroy)
-        {
-            Destroy(effectObj, destroyDelay);
-        }
-        
-        return effectObj;
+        return player;
     }
     
-    /// <summary>
-    /// 鍦ㄤ袱涓猆I鍏冪礌涔嬮棿鎾斁鐗规晥锛堟寜鐓ortingOrder鐨勪腑闂村�硷級
-    /// </summary>
-    /// <param name="effectName">鐗规晥璧勬簮鍚嶇О</param>
-    /// <param name="frontElement">鍓嶆櫙UI鍏冪礌锛圛mage鎴朢awImage锛�</param>
-    /// <param name="backElement">鑳屾櫙UI鍏冪礌锛圛mage鎴朢awImage锛�</param>
-    /// <param name="autoDestroy">鏄惁鑷姩閿�姣侊紝榛樿涓簍rue</param>
-    /// <param name="destroyDelay">鑷姩閿�姣佸欢杩熸椂闂达紝榛樿涓�5绉�</param>
-    /// <returns>鐗规晥娓告垙瀵硅薄</returns>
-    public async UniTask<GameObject> PlayEffectBetweenUIElements(string effectName, Graphic frontElement, Graphic backElement, bool autoDestroy = true, float destroyDelay = 5f)
-    {
-        if (frontElement == null || backElement == null)
-        {
-            Debug.LogError("鍓嶆櫙鎴栬儗鏅疷I鍏冪礌涓虹┖");
-            return null;
-        }
-        
-        // 纭繚UI鍏冪礌鍦ㄥ綋鍓峌IBase鐨凜anvas涓�
-        if (frontElement.canvas != canvas || backElement.canvas != canvas)
-        {
-            Debug.LogError("UI鍏冪礌涓嶅湪褰撳墠UIBase鐨凜anvas涓�");
-            return null;
-        }
-        
-        // 鍔犺浇鐗规晥璧勬簮
-        GameObject effectPrefab = ResManager.Instance.LoadAsset<GameObject>("UIEffect", effectName);
-        if (effectPrefab == null)
-        {
-            Debug.LogError($"鍔犺浇UI鐗规晥澶辫触: {effectName}");
-            return null;
-        }
-        
-        // 鍒涘缓涓�涓柊鐨凣ameObject浣滀负鐗规晥瀹瑰櫒
-        GameObject container = new GameObject($"EffectContainer_{effectName}");
-        container.transform.SetParent(transform, false);
-        
-        // 璁剧疆瀹瑰櫒浣嶇疆
-        RectTransform containerRect = container.AddComponent<RectTransform>();
-        containerRect.anchorMin = new Vector2(0.5f, 0.5f);
-        containerRect.anchorMax = new Vector2(0.5f, 0.5f);
-        containerRect.pivot = new Vector2(0.5f, 0.5f);
-        containerRect.anchoredPosition = Vector2.zero;
-        containerRect.sizeDelta = new Vector2(100, 100); // 榛樿澶у皬锛屽彲浠ユ牴鎹渶瑕佽皟鏁�
-        
-        // 鑾峰彇鍓嶆櫙鍜岃儗鏅厓绱犵殑siblingIndex
-        int frontIndex = frontElement.transform.GetSiblingIndex();
-        int backIndex = backElement.transform.GetSiblingIndex();
-        
-        // 璁剧疆鐗规晥瀹瑰櫒鐨剆iblingIndex鍦ㄤ袱鑰呬箣闂�
-        if (frontIndex > backIndex)
-        {
-            // 鍓嶆櫙鍦ㄨ儗鏅箣鍚庯紝鐗规晥搴旇鍦ㄤ腑闂�
-            container.transform.SetSiblingIndex((frontIndex + backIndex) / 2 + 1);
-        }
-        else
-        {
-            // 鑳屾櫙鍦ㄥ墠鏅箣鍚庯紝鐗规晥搴旇鍦ㄤ腑闂�
-            container.transform.SetSiblingIndex((frontIndex + backIndex) / 2);
-        }
-        
-        // 瀹炰緥鍖栫壒鏁�
-        GameObject effectObj = Instantiate(effectPrefab, container.transform);
-        effectObj.name = $"Effect_{effectName}";
-        
-        // 娣诲姞鐗规晥绌块�忛樆鎸″櫒
-        EffectPenetrationBlocker blocker = effectObj.AddComponent<EffectPenetrationBlocker>();
-        
-        // 鐩存帴璁剧疆鐗规晥娓叉煋鍣ㄧ殑鎺掑簭椤哄簭
-        Renderer[] renderers = effectObj.GetComponentsInChildren<Renderer>(true);
-        foreach (Renderer renderer in renderers)
-        {
-            renderer.sortingOrder = canvas.sortingOrder;
-            renderer.sortingLayerName = canvas.sortingLayerName;
-        }
-        
-        // 璁剧疆绮掑瓙绯荤粺娓叉煋鍣ㄧ殑鎺掑簭椤哄簭
-        ParticleSystem[] particleSystems = effectObj.GetComponentsInChildren<ParticleSystem>(true);
-        foreach (ParticleSystem ps in particleSystems)
-        {
-            ParticleSystemRenderer psRenderer = ps.GetComponent<ParticleSystemRenderer>();
-            if (psRenderer != null)
-            {
-                psRenderer.sortingOrder = canvas.sortingOrder;
-                psRenderer.sortingLayerName = canvas.sortingLayerName;
-            }
-        }
-        
-        // 鑷姩閿�姣�
-        if (autoDestroy)
-        {
-            Destroy(container, destroyDelay);
-        }
-        
-        return effectObj;
-    }
     #endregion
 
     public bool raycastTarget

--
Gitblit v1.8.0