From f4c97339a01fdd75d8b862be572eefe66bd51d5a Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期五, 16 五月 2025 19:18:21 +0800
Subject: [PATCH] update

---
 Main/Utility/ComponentExtersion.cs |   80 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 79 insertions(+), 1 deletions(-)

diff --git a/Main/Utility/ComponentExtersion.cs b/Main/Utility/ComponentExtersion.cs
index 6e55ccf..59b3c8f 100644
--- a/Main/Utility/ComponentExtersion.cs
+++ b/Main/Utility/ComponentExtersion.cs
@@ -26,7 +26,7 @@
         }
         catch (Exception ex)
         {
-            Debug.Log(ex);
+            DebugEx.Log(ex);
             return null;
         }
 
@@ -216,6 +216,84 @@
         dropdown.onValueChanged.AddListener(action);
     }
 
+    // public static void SetEnable(this Button _btn, Text _btnTxt, bool _enable, EnableButtonConfig.EnableButtonType _type =
+    //     EnableButtonConfig.EnableButtonType.Default)
+    // {
+    //     EnableButtonConfig.SetEnable(_btn, _btnTxt, _enable, _type);
+    // }
+
+    
+    public static void SetColorful(this Button _btn, Text _btnTxt, bool _colorful, int pattern = 0)
+    {
+        if (_btn != null)
+        {
+            var imageEx = _btn.image as ImageEx;
+            if (imageEx != null)
+            {
+                imageEx.gray = !_colorful;
+            }
+        }
+        if (_btnTxt != null)
+        {
+            switch (pattern)
+            {
+                case 1:
+                    _btnTxt.color = UIHelper.GetUIColor(_colorful ? TextColType.LightYellow : TextColType.White);
+                    break;
+                case 2:
+                    _btnTxt.color = UIHelper.GetUIColor(_colorful ? TextColType.Green : TextColType.White);
+                    break;
+                default:
+                    _btnTxt.color = UIHelper.GetUIColor(_colorful ? TextColType.NavyBrown : TextColType.White);
+                    break;
+            }
+        }
+    }
+
+    
+    public static void SetInteractable(this Button _btn, Text _btnText, bool _interactable)
+    {
+        if (_btn != null)
+        {
+            _btn.interactable = _interactable;
+            var imageEx = _btn.image as ImageEx;
+            if (imageEx != null)
+            {
+                imageEx.gray = !_interactable;
+            }
+        }
+        if (_btnText != null)
+        {
+            _btnText.color = UIHelper.GetUIColor(_interactable ? TextColType.NavyBrown : TextColType.White);
+            //_btnText.color = _btnText.color.SetA(_interactable ? 1 : 0.5f);
+        }
+    }
+
+    
+    public static void SetSprite(this Image _image, string _id)
+    {
+        if (_image == null)
+        {
+            return;
+        }
+
+        var sprite = UILoader.LoadSprite(_id);
+        _image.overrideSprite = sprite;
+    }
+
+    
+    public static void SetSprite(this TextImage _textImage, string _id)
+    {
+        if (_textImage == null)
+        {
+            return;
+        }
+
+        var sprite = UILoader.LoadSprite(_id);
+        _textImage.sprite = sprite;
+    }
+
+
     public static void SetActive(this Component compoent, bool active)
     {
         if (compoent != null)

--
Gitblit v1.8.0