yyl
2025-08-11 b2d7bb59dc37c7b350786b076ee2f344b7c8911f
Main/Utility/ComponentExtersion.cs
@@ -80,7 +80,7 @@
        return component;
    }
    public static void AddListener(this Button _button, UnityAction _action)
    {
        if (_button == null)
@@ -92,7 +92,7 @@
        _button.onClick.AddListener(_action);
    }
    public static void RemoveAllListeners(this Button _button)
    {
        if (_button == null)
@@ -102,7 +102,7 @@
        _button.onClick.RemoveAllListeners();
    }
    public static void SetListener(this Button button, UnityAction action)
    {
        if (button == null)
@@ -124,7 +124,7 @@
        _toggle.onValueChanged.AddListener(_action);
    }
    public static void SetListener(this Toggle toggle, UnityAction<bool> action)
    {
        if (toggle == null)
@@ -145,7 +145,7 @@
        _toggle.onValueChanged.RemoveAllListeners();
    }
    public static void AddListener(this Slider _slider, UnityAction<float> _action)
    {
        if (_slider == null)
@@ -155,7 +155,7 @@
        _slider.onValueChanged.AddListener(_action);
    }
    public static void SetListener(this Slider slider, UnityAction<float> action)
    {
        if (slider == null)
@@ -176,7 +176,7 @@
        _slider.onValueChanged.RemoveAllListeners();
    }
    public static void AddListener(this InputField _inputField, UnityAction<string> _action)
    {
        if (_inputField == null)
@@ -197,7 +197,7 @@
        inputField.onValueChanged.AddListener(action);
    }
    public static void RemoveAllListeners(this InputField _inputField)
    {
        if (_inputField == null)
@@ -223,7 +223,7 @@
    //     EnableButtonConfig.SetEnable(_btn, _btnTxt, _enable, _type);
    // }
    public static void SetColorful(this Button _btn, Text _btnTxt, bool _colorful, int pattern = 0)
    {
        if (_btn != null)
@@ -251,7 +251,7 @@
        }
    }
    public static void SetInteractable(this Button _btn, Text _btnText, bool _interactable)
    {
        if (_btn != null)
@@ -282,7 +282,7 @@
        _image.overrideSprite = sprite;
    }
    public static void SetSprite(this TextImage _textImage, string _id)
    {
        if (_textImage == null)
@@ -294,7 +294,7 @@
        _textImage.sprite = sprite;
    }
    //通过图片名加载
    //通过图片名加载, 如物品表 技能表等,节省在Icon表做多余配置
    public static void SetOrgSprite(this Image _image, string iconName, string folderName = "icon")
    {
        if (_image == null)
@@ -321,4 +321,15 @@
        }
    }
    public static void SetTexture2D(this RawImage _image, string _id)
    {
        if (_image == null)
        {
            return;
        }
        var texture = UILoader.LoadTexture2D(_id);
        _image.texture = texture;
    }
}