| | |
| | | } |
| | | |
| | | |
| | | public static void SetInteractable(this Button _btn, Text _btnText, bool _interactable) |
| | | // 设置按钮是否可点击,且置灰,默认取第一个文本;图片需用ImageEx组件 |
| | | // 更多功能请使用SetColorful |
| | | public static void SetInteractable(this Button _btn, bool _interactable, Text _btnText = null) |
| | | { |
| | | if (_btn != null) |
| | | { |
| | |
| | | imageEx.gray = !_interactable; |
| | | } |
| | | } |
| | | if (_btnText == null) |
| | | _btnText = _btn.GetComponentInChildren<Text>(); |
| | | if (_btnText != null) |
| | | { |
| | | _btnText.color = UIHelper.GetUIColor(_interactable ? TextColType.NavyBrown : TextColType.White); |
| | | //_btnText.color = _btnText.color.SetA(_interactable ? 1 : 0.5f); |
| | | //false 灰色,true 原色 |
| | | if (!_interactable) |
| | | _btnText.text = UIHelper.AppendColor(TextColType.NavyGray, _btnText.text); //不改变组件颜色,只改变显示颜色 |
| | | else |
| | | _btnText.text = UIHelper.AppendColor(_btnText.color, _btnText.text); |
| | | } |
| | | } |
| | | |