using System; using CIG.Translation; using UnityEngine; using UnityEngine.UI; namespace CIG { [ExecuteInEditMode] public class InteractableButton : MonoBehaviour { public bool Interactable { get { return this._interactable; } set { this._interactable = value; this._button.interactable = value; this.UpdateLook(); } } public void SetText(ILocalizedString text) { this._text.LocalizedString = text; } private void UpdateLook() { if (this._image != null) { this._image.sprite = ((!this._interactable) ? this._nonInteractableButtonSprite : this._interactableButtonSprite); } if (this._text != null) { this._text.TextField.color = ((!this._interactable) ? this._nonInteractableTextColor : this._interactableTextColor); } if (this._textShadow != null) { this._textShadow.effectColor = ((!this._interactable) ? this._nonInteractableTextOutlineColor : this._interactableTextOutlineColor); } } [SerializeField] private Image _image; [SerializeField] private Button _button; [SerializeField] private LocalizedText _text; [SerializeField] private Shadow _textShadow; [SerializeField] private bool _interactable; [SerializeField] [Space(8f)] private Sprite _interactableButtonSprite; [SerializeField] private Color _interactableTextColor; [SerializeField] private Color _interactableTextOutlineColor; [SerializeField] [Space(8f)] private Sprite _nonInteractableButtonSprite; [SerializeField] private Color _nonInteractableTextColor; [SerializeField] private Color _nonInteractableTextOutlineColor; } }