using System.Collections; 
 | 
using System.Collections.Generic; 
 | 
using UnityEngine; 
 | 
using System; 
 | 
using UnityEngine.UI; 
 | 
[CreateAssetMenu(menuName = "Config/EnableButtonConfig")] 
 | 
public class EnableButtonConfig : ScriptableObject 
 | 
{ 
 | 
    [SerializeField] EnableButtonType type; 
 | 
    [SerializeField] EnableButtonStyle enableButton; 
 | 
    [SerializeField] EnableButtonStyle unEnableButton; 
 | 
  
 | 
    public static Dictionary<EnableButtonType, EnableButtonConfig> dict = new Dictionary<EnableButtonType, EnableButtonConfig>(); 
 | 
  
 | 
    public static void SetEnable(Button _btn, Text _text, bool _enable, EnableButtonType _type) 
 | 
    { 
 | 
        var _cfg = GetEnableButtonCfg(_type); 
 | 
        var _btnStyle = _enable ? _cfg.enableButton : _cfg.unEnableButton; 
 | 
        _btn.interactable = _enable; 
 | 
        var _colors = _btn.colors; 
 | 
        _colors.disabledColor = Color.white; 
 | 
        _btn.colors = _colors; 
 | 
        _btn.image.SetSprite(_btnStyle.iconKey); 
 | 
        _text.fontSize = _btnStyle.fontSize; 
 | 
        _text.color = _btnStyle.fontColor; 
 | 
    } 
 | 
  
 | 
    public static EnableButtonConfig GetEnableButtonCfg(EnableButtonType _type) 
 | 
    { 
 | 
        if (dict.ContainsKey(_type)) 
 | 
        { 
 | 
            return dict[_type]; 
 | 
        } 
 | 
        var _cfg= BuiltInLoader.LoadScriptableObject<EnableButtonConfig>(StringUtility.Contact("EnableButton_", _type)); 
 | 
        dict.Add(_type, _cfg); 
 | 
        return _cfg; 
 | 
    } 
 | 
  
 | 
    [Serializable] 
 | 
    public struct EnableButtonStyle 
 | 
    { 
 | 
        public string iconKey; 
 | 
        public Color fontColor; 
 | 
        public int fontSize; 
 | 
    } 
 | 
  
 | 
    public enum EnableButtonType 
 | 
    { 
 | 
        Default, 
 | 
    } 
 | 
} 
 |