From 87d5c46997d61523aed87fdb7ed0b07e9dded223 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期二, 30 九月 2025 21:45:08 +0800
Subject: [PATCH] 0312 优化淘金派遣

---
 Main/System/SkillUI/SkillBaseCell.cs |   63 ++++++++++++++++++++++++++++---
 1 files changed, 57 insertions(+), 6 deletions(-)

diff --git a/Main/System/SkillUI/SkillBaseCell.cs b/Main/System/SkillUI/SkillBaseCell.cs
index d8dd906..934ef53 100644
--- a/Main/System/SkillUI/SkillBaseCell.cs
+++ b/Main/System/SkillUI/SkillBaseCell.cs
@@ -45,24 +45,57 @@
         }
     }
 
+    Image m_WordBG;
+    Image wordBG
+    {
+        get
+        {
+            if (m_WordBG == null)
+            {
+                m_WordBG = this.transform.GetComponent<Image>("Container_SkillCell/Image");
+            }
+            return m_WordBG;
+        }
+    }
+
+
     void Awake()
     {
         LoadPrefab();
     }
 
-    private void Init(int skillID, UnityAction onclick, bool showType = false)
+    public void Init(int skillID, UnityAction onclick = null, bool showType = false)
     {
+        LoadPrefab();   //瀛樺湪琚嵏杞界殑鍙兘锛岄噸鏂板姞杞�
         var config = SkillConfig.Get(skillID);
-        skillIcon.SetSprite(config.IconName);
-        skillBtn.AddListener(onclick);
+        if (config == null)
+        {
+            Debug.LogErrorFormat("鎶�鑳芥湭閰嶇疆 : {0}", skillID);
+            return;
+        }
+        skillIcon.SetOrgSprite(config.IconName, "SkillIcon");
+#if UNITY_EDITOR
+        if (string.IsNullOrEmpty(config.IconName))
+        { 
+            //鍐呯綉娴嬭瘯
+            skillIcon.SetOrgSprite("skillicondefault", "SkillIcon");
+        }
+#endif
+        
+        skillBtn.AddListener(()=>
+        {
+            onclick?.Invoke();
+        });
 
         if (showType)
         {
-            skillType.text = Language.Get(config.FuncType == 23 ? "HeroSkillType_1" : "HeroSkillType_2");
+            skillType.text = Language.Get(config.FuncType == 1 ? "HeroSkillType_1" : "HeroSkillType_2");
+            wordBG.SetActive(true);
         }
         else
-        { 
+        {
             skillType.text = string.Empty;
+            wordBG.SetActive(false);
         }
     }
 
@@ -71,7 +104,7 @@
     {
         if (cellContainer != null)
             return;
-        
+
         var tmp = transform.Find("Container_SkillCell");
         if (tmp != null)
         {
@@ -88,6 +121,24 @@
                 cellContainer.transform.SetAsFirstSibling();
             }
         }
+        
+        //缂╂斁鍒板拰鐖秗ect涓�鏍峰ぇ
+        var scale = 1f;
+        var rect = cellContainer.GetComponent<RectTransform>();
+        var parentRect = transform.GetComponent<RectTransform>();
+        float width = parentRect.sizeDelta.x;
+        if (width <= 0f)
+        {
+            //澶栭儴鎺у埗浜嗗昂瀵歌幏鍙栦负0
+            GridLayoutGroup grid = GetComponentInParent<GridLayoutGroup>();
+            if (grid != null)
+            { 
+                width = grid.cellSize.x;
+            }
+            
+        }
+        scale = width / rect.sizeDelta.x;
+        cellContainer.transform.localScale = cellContainer.transform.localScale * scale;
     }
 }
 

--
Gitblit v1.8.0