You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

82 lines
1.7 KiB

  1. using System;
  2. using CIG.Translation;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. namespace CIG
  6. {
  7. [ExecuteInEditMode]
  8. public class InteractableButton : MonoBehaviour
  9. {
  10. public bool Interactable
  11. {
  12. get
  13. {
  14. return this._interactable;
  15. }
  16. set
  17. {
  18. this._interactable = value;
  19. this._button.interactable = value;
  20. this.UpdateLook();
  21. }
  22. }
  23. public void SetText(ILocalizedString text)
  24. {
  25. this._text.LocalizedString = text;
  26. }
  27. private void UpdateLook()
  28. {
  29. if (this._image != null)
  30. {
  31. this._image.sprite = ((!this._interactable) ? this._nonInteractableButtonSprite : this._interactableButtonSprite);
  32. }
  33. if (this._text != null)
  34. {
  35. this._text.TextField.color = ((!this._interactable) ? this._nonInteractableTextColor : this._interactableTextColor);
  36. }
  37. if (this._textShadow != null)
  38. {
  39. this._textShadow.effectColor = ((!this._interactable) ? this._nonInteractableTextOutlineColor : this._interactableTextOutlineColor);
  40. }
  41. }
  42. [SerializeField]
  43. private Image _image;
  44. [SerializeField]
  45. private Button _button;
  46. [SerializeField]
  47. private LocalizedText _text;
  48. [SerializeField]
  49. private Shadow _textShadow;
  50. [SerializeField]
  51. private bool _interactable;
  52. [SerializeField]
  53. [Space(8f)]
  54. private Sprite _interactableButtonSprite;
  55. [SerializeField]
  56. private Color _interactableTextColor;
  57. [SerializeField]
  58. private Color _interactableTextOutlineColor;
  59. [SerializeField]
  60. [Space(8f)]
  61. private Sprite _nonInteractableButtonSprite;
  62. [SerializeField]
  63. private Color _nonInteractableTextColor;
  64. [SerializeField]
  65. private Color _nonInteractableTextOutlineColor;
  66. }
  67. }