| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Debug.Log(ex); |
| | | DebugEx.Log(ex); |
| | | return null; |
| | | } |
| | | |
| | |
| | | dropdown.onValueChanged.AddListener(action); |
| | | } |
| | | |
| | | // public static void SetEnable(this Button _btn, Text _btnTxt, bool _enable, EnableButtonConfig.EnableButtonType _type = |
| | | // EnableButtonConfig.EnableButtonType.Default) |
| | | // { |
| | | // EnableButtonConfig.SetEnable(_btn, _btnTxt, _enable, _type); |
| | | // } |
| | | |
| | | |
| | | public static void SetColorful(this Button _btn, Text _btnTxt, bool _colorful, int pattern = 0) |
| | | { |
| | | if (_btn != null) |
| | | { |
| | | var imageEx = _btn.image as ImageEx; |
| | | if (imageEx != null) |
| | | { |
| | | imageEx.gray = !_colorful; |
| | | } |
| | | } |
| | | if (_btnTxt != null) |
| | | { |
| | | switch (pattern) |
| | | { |
| | | case 1: |
| | | _btnTxt.color = UIHelper.GetUIColor(_colorful ? TextColType.LightYellow : TextColType.White); |
| | | break; |
| | | case 2: |
| | | _btnTxt.color = UIHelper.GetUIColor(_colorful ? TextColType.Green : TextColType.White); |
| | | break; |
| | | default: |
| | | _btnTxt.color = UIHelper.GetUIColor(_colorful ? TextColType.NavyBrown : TextColType.White); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | public static void SetInteractable(this Button _btn, Text _btnText, bool _interactable) |
| | | { |
| | | if (_btn != null) |
| | | { |
| | | _btn.interactable = _interactable; |
| | | var imageEx = _btn.image as ImageEx; |
| | | if (imageEx != null) |
| | | { |
| | | imageEx.gray = !_interactable; |
| | | } |
| | | } |
| | | if (_btnText != null) |
| | | { |
| | | _btnText.color = UIHelper.GetUIColor(_interactable ? TextColType.NavyBrown : TextColType.White); |
| | | //_btnText.color = _btnText.color.SetA(_interactable ? 1 : 0.5f); |
| | | } |
| | | } |
| | | |
| | | |
| | | public static void SetSprite(this Image _image, string _id) |
| | | { |
| | | if (_image == null) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | var sprite = UILoader.LoadSprite(_id); |
| | | _image.overrideSprite = sprite; |
| | | } |
| | | |
| | | |
| | | public static void SetSprite(this TextImage _textImage, string _id) |
| | | { |
| | | if (_textImage == null) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | var sprite = UILoader.LoadSprite(_id); |
| | | _textImage.sprite = sprite; |
| | | } |
| | | |
| | | |
| | | public static void SetActive(this Component compoent, bool active) |
| | | { |
| | | if (compoent != null) |