From ed98029a88cd89702980ac7c40b711afddc5aeb2 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期四, 20 十一月 2025 14:44:59 +0800
Subject: [PATCH] Merge branch 'master' of http://mobile.secondworld.net.cn:10010/r/Project_SG_scripts
---
Main/Utility/ComponentExtersion.cs | 98 +++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 94 insertions(+), 4 deletions(-)
diff --git a/Main/Utility/ComponentExtersion.cs b/Main/Utility/ComponentExtersion.cs
index 7d6eb58..c7aadbc 100644
--- a/Main/Utility/ComponentExtersion.cs
+++ b/Main/Utility/ComponentExtersion.cs
@@ -255,8 +255,44 @@
}
}
-
- public static void SetInteractable(this Button _btn, Text _btnText, bool _interactable)
+ public static void SetColorful(this GroupButtonEx _btn, Text _btnTxt, bool _colorful, int pattern = 0)
+ {
+ if (_btn != null)
+ {
+ if (_btn.selectIcon != null)
+ {
+ _btn.selectIcon.gray = !_colorful;
+ }
+ if (_btn.unSelectIcon != null)
+ {
+ _btn.unSelectIcon.gray = !_colorful;
+ }
+ }
+ if (_btnTxt != null)
+ {
+ switch (pattern)
+ {
+ case 1:
+ _btnTxt.color = UIHelper.GetUIColor(_colorful ? TextColType.LightWhite : TextColType.White);
+ break;
+ case 2:
+ _btnTxt.color = UIHelper.GetUIColor(_colorful ? TextColType.Green : TextColType.White);
+ break;
+ default:
+ //false 鐏拌壊锛宼rue 鍘熻壊
+ if (!_colorful)
+ _btnTxt.text = UIHelper.AppendColor(TextColType.NavyGray, _btnTxt.text); //涓嶆敼鍙樼粍浠堕鑹诧紝鍙敼鍙樻樉绀洪鑹�
+ else
+ _btnTxt.text = UIHelper.AppendColor(_btnTxt.color, _btnTxt.text);
+ break;
+ }
+ }
+ }
+
+ // 璁剧疆鎸夐挳鏄惁鍙偣鍑伙紝涓斿彇绗竴涓枃鏈粍浠剁疆鐏版垨缃師鑹�
+ // 瑕佸厛璁剧疆鏂囨湰鍐嶈皟鐢ㄨ鍑芥暟 鍥犱负娌℃湁鏀瑰彉鏂囨湰缁勪欢鐨勯鑹查伩鍏嶉鑹茶杩樺師锛屽悓鐞嗘仮澶嶅彲浠ヤ笉鐢ㄦ敼鍙橀鑹叉敼鏂囧瓧鍗冲彲
+ // 鏇村鍔熻兘璇蜂娇鐢⊿etColorful
+ public static void SetInteractable(this Button _btn, bool _interactable, Text _btnText = null)
{
if (_btn != null)
{
@@ -267,10 +303,15 @@
imageEx.gray = !_interactable;
}
}
+ if (_btnText == null)
+ _btnText = _btn.GetComponentInChildren<Text>();
if (_btnText != null)
{
- _btnText.color = UIHelper.GetUIColor(_interactable ? TextColType.NavyBrown : TextColType.White);
- //_btnText.color = _btnText.color.SetA(_interactable ? 1 : 0.5f);
+ //false 鐏拌壊锛宼rue 鍘熻壊
+ if (!_interactable)
+ _btnText.text = UIHelper.AppendColor(TextColType.NavyGray, _btnText.text); //涓嶆敼鍙樼粍浠堕鑹诧紝鍙敼鍙樻樉绀洪鑹�
+ else
+ _btnText.text = UIHelper.AppendColor(_btnText.color, UIHelper.RemoveColor(_btnText.text));
}
}
@@ -279,6 +320,12 @@
{
if (_image == null)
{
+ return;
+ }
+
+ if (string.IsNullOrEmpty(_id))
+ {
+ Debug.LogError("Image SetSprite id is null or empty " + _id);
return;
}
@@ -294,6 +341,12 @@
return;
}
+ if (string.IsNullOrEmpty(_id))
+ {
+ Debug.LogError("TextImage SetSprite id is null or empty " + _id);
+ return;
+ }
+
var sprite = UILoader.LoadSprite(_id);
_textImage.sprite = sprite;
}
@@ -306,7 +359,14 @@
return;
}
+ if (string.IsNullOrEmpty(iconName))
+ {
+ Debug.LogError("SetOrgSprite iconName is null or empty " + iconName);
+ return;
+ }
+
var sprite = UILoader.LoadSprite(folderName, iconName);
+ if (null == sprite) return;
_image.overrideSprite = sprite;
}
@@ -320,6 +380,12 @@
var itemConfig = ItemConfig.Get(itemID);
if (itemConfig == null)
{
+ return;
+ }
+
+ if (string.IsNullOrEmpty(itemConfig.IconKey))
+ {
+ Debug.LogError("SetItemSprite IconKey is null or empty for itemID " + itemID);
return;
}
@@ -337,6 +403,12 @@
var skillConfig = SkillConfig.Get(skillID);
if (skillConfig == null)
{
+ return;
+ }
+
+ if (string.IsNullOrEmpty(skillConfig.IconName))
+ {
+ Debug.LogError("SetSkillSprite IconName is null or empty for skillID " + skillID);
return;
}
@@ -370,4 +442,22 @@
var texture = UILoader.LoadTexture2D(_id);
_image.texture = texture;
}
+
+
+ public static void SetTexture2DPNG(this RawImage _image, string _id)
+ {
+ if (_image == null)
+ {
+ return;
+ }
+
+ if (string.IsNullOrEmpty(_id))
+ {
+ Debug.LogError("SetTexture2DPNG id is null or empty " + _id);
+ return;
+ }
+
+ var texture = UILoader.LoadTexture2DPNG(_id);
+ _image.texture = texture;
+ }
}
--
Gitblit v1.8.0