OnaholeNodeButton.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class OnaholeNodeButton : MonoBehaviour, IOnaholeNodeButton
  5. {
  6. public string text
  7. {
  8. get
  9. {
  10. return this.textLabel.text;
  11. }
  12. set
  13. {
  14. this.textLabel.text = ((!string.IsNullOrEmpty(value)) ? value : string.Empty);
  15. }
  16. }
  17. public bool visibleNextMarker
  18. {
  19. get
  20. {
  21. return this.nextMarker.activeSelf;
  22. }
  23. set
  24. {
  25. this.nextMarker.SetActive(value);
  26. this.textLabel.rightAnchor.absolute = ((!value) ? 0 : -30);
  27. UIRect.AnchorUpdate updateAnchors = this.textLabel.updateAnchors;
  28. this.textLabel.updateAnchors = UIRect.AnchorUpdate.OnUpdate;
  29. this.textLabel.UpdateAnchors();
  30. this.textLabel.updateAnchors = updateAnchors;
  31. }
  32. }
  33. public bool sizeModeBig
  34. {
  35. set
  36. {
  37. this.bg.width = ((!value) ? 250 : 380);
  38. List<UIRect> list = new List<UIRect>();
  39. list.Add(this.textLabel);
  40. if (this.nextMarker.GetComponent<UIRect>() != null)
  41. {
  42. list.Add(this.nextMarker.GetComponent<UIRect>());
  43. }
  44. foreach (UIRect uirect in list)
  45. {
  46. UIRect.AnchorUpdate updateAnchors = uirect.updateAnchors;
  47. uirect.updateAnchors = UIRect.AnchorUpdate.OnUpdate;
  48. uirect.UpdateAnchors();
  49. uirect.updateAnchors = updateAnchors;
  50. }
  51. }
  52. }
  53. public string uniqueName { get; set; }
  54. public OnaholeNodeButton.SelectType selectType
  55. {
  56. get
  57. {
  58. return this.selectType_;
  59. }
  60. set
  61. {
  62. this.selectType_ = value;
  63. if (value == OnaholeNodeButton.SelectType.None)
  64. {
  65. this.bg.alpha = this.defaultBGAlpha;
  66. this.textLabel.color = Color.white;
  67. }
  68. else if (value == OnaholeNodeButton.SelectType.Focus)
  69. {
  70. this.bg.alpha = 1f;
  71. this.textLabel.color = Color.white;
  72. }
  73. else if (value == OnaholeNodeButton.SelectType.Select)
  74. {
  75. this.bg.alpha = 1f;
  76. this.textLabel.color = Color.yellow;
  77. }
  78. else if (value == OnaholeNodeButton.SelectType.Disable)
  79. {
  80. this.bg.alpha = 0.2f;
  81. this.textLabel.color = Color.gray;
  82. }
  83. }
  84. }
  85. public void Awake()
  86. {
  87. this.defaultBGAlpha = this.bg.alpha;
  88. this.selectType = OnaholeNodeButton.SelectType.None;
  89. this.sizeModeBig = false;
  90. }
  91. GameObject IOnaholeNodeButton.get_gameObject()
  92. {
  93. return base.gameObject;
  94. }
  95. [SerializeField]
  96. private UIWidget bg;
  97. [SerializeField]
  98. private UILabel textLabel;
  99. [SerializeField]
  100. private GameObject nextMarker;
  101. private float defaultBGAlpha;
  102. private OnaholeNodeButton.SelectType selectType_;
  103. public enum SelectType
  104. {
  105. None,
  106. Focus,
  107. Select,
  108. Disable
  109. }
  110. }