| | |
| | | using UnityEngine; |
| | | using System; |
| | | using UnityEngine.UI; |
| | | using Cysharp.Threading.Tasks; |
| | | [CreateAssetMenu(menuName = "Config/EnableButtonConfig")] |
| | | public class EnableButtonConfig : ScriptableObject |
| | | { |
| | |
| | | |
| | | public static Dictionary<EnableButtonType, EnableButtonConfig> dict = new Dictionary<EnableButtonType, EnableButtonConfig>(); |
| | | |
| | | public static void SetEnable(Button _btn, Text _text, bool _enable, EnableButtonType _type) |
| | | public static async UniTask SetEnable(Button _btn, Text _text, bool _enable, EnableButtonType _type) |
| | | { |
| | | var _cfg = GetEnableButtonCfg(_type); |
| | | var _cfg = await GetEnableButtonCfg(_type); |
| | | var _btnStyle = _enable ? _cfg.enableButton : _cfg.unEnableButton; |
| | | _btn.interactable = _enable; |
| | | var _colors = _btn.colors; |
| | |
| | | _text.color = _btnStyle.fontColor; |
| | | } |
| | | |
| | | public static EnableButtonConfig GetEnableButtonCfg(EnableButtonType _type) |
| | | public static async UniTask<EnableButtonConfig> GetEnableButtonCfg(EnableButtonType _type) |
| | | { |
| | | if (dict.ContainsKey(_type)) |
| | | { |
| | | return dict[_type]; |
| | | } |
| | | var _cfg= BuiltInLoader.LoadScriptableObject<EnableButtonConfig>(StringUtility.Concat("EnableButton_", _type.ToString())); |
| | | var _cfg = await BuiltInLoader.LoadScriptableObjectAsync<EnableButtonConfig>(StringUtility.Concat("EnableButton_", _type.ToString())); |
| | | dict.Add(_type, _cfg); |
| | | return _cfg; |
| | | } |