少年修仙传客户端代码仓库
client_Wu Xijin
2018-09-12 2c47a125bed8e36b50163149f0998381e08bf610
3335 代码维护 ,扩展UI基础API
1个文件已修改
44 ■■■■■ 已修改文件
Utility/ComponentExtersion.cs 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Utility/ComponentExtersion.cs
@@ -75,6 +75,17 @@
        _button.onClick.RemoveAllListeners();
    }
    public static void SetListener(this Button button, UnityAction action)
    {
        if (button == null)
        {
            return;
        }
        button.onClick.RemoveAllListeners();
        button.AddListener(action);
    }
    public static void AddListener(this Toggle _toggle, UnityAction<bool> _action)
    {
        if (_toggle == null)
@@ -82,6 +93,17 @@
            return;
        }
        _toggle.onValueChanged.AddListener(_action);
    }
    public static void SetListener(this Toggle toggle, UnityAction<bool> action)
    {
        if (toggle == null)
        {
            return;
        }
        toggle.onValueChanged.RemoveAllListeners();
        toggle.onValueChanged.AddListener(action);
    }
    public static void RemoveAllListeners(this Toggle _toggle)
@@ -102,6 +124,17 @@
        _slider.onValueChanged.AddListener(_action);
    }
    public static void SetListener(this Slider slider, UnityAction<float> action)
    {
        if (slider == null)
        {
            return;
        }
        slider.onValueChanged.RemoveAllListeners();
        slider.onValueChanged.AddListener(action);
    }
    public static void RemoveAllListeners(this Slider _slider)
    {
        if (_slider == null)
@@ -120,6 +153,17 @@
        _inputField.onValueChanged.AddListener(_action);
    }
    public static void SetListener(this InputField inputField, UnityAction<string> action)
    {
        if (inputField == null)
        {
            return;
        }
        inputField.onValueChanged.RemoveAllListeners();
        inputField.onValueChanged.AddListener(action);
    }
    public static void RemoveAllListeners(this InputField _inputField)
    {
        if (_inputField == null)