using System; using CIG.Translation; using UnityEngine; using UnityEngine.UI; public class ToggleButton : MonoBehaviour { public void SetState(bool isEnabled) { this.SetState(isEnabled, null); } public void SetState(bool isEnabled, ILocalizedString text) { if (this._text != null) { this._text.LocalizedString = text; } if (isEnabled) { this._buttonImage.sprite = this._enabledButtonSprite; if (this._text != null) { this._text.TextField.color = this._enabledTextColor; } if (this._textShadow != null) { this._textShadow.effectColor = this._enabledShadowColor; } } else { this._buttonImage.sprite = this._disabledButtonSprite; if (this._text != null) { this._text.TextField.color = this._disabledTextColor; } if (this._textShadow != null) { this._textShadow.effectColor = this._disabledShadowColor; } } } [SerializeField] private Image _buttonImage; [SerializeField] private Sprite _enabledButtonSprite; [SerializeField] private Sprite _disabledButtonSprite; [SerializeField] [Tooltip("(Optional)")] private LocalizedText _text; [SerializeField] private Color _enabledTextColor; [SerializeField] private Color _disabledTextColor; [SerializeField] [Tooltip("(Optional)")] private Shadow _textShadow; [SerializeField] private Color _enabledShadowColor; [SerializeField] private Color _disabledShadowColor; }