HighlightSelector.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. using System;
  2. using UnityEngine;
  3. namespace CharacterEdit
  4. {
  5. public class HighlightSelector : MonoBehaviour
  6. {
  7. public HighlightSelector.SelectItem selectItem
  8. {
  9. get
  10. {
  11. UIWFTabButton selectButtonObject = this.panel.GetSelectButtonObject();
  12. foreach (HighlightSelector.Data data in this.datas)
  13. {
  14. if (selectButtonObject == data.button)
  15. {
  16. return data.type;
  17. }
  18. }
  19. return HighlightSelector.SelectItem.Eye;
  20. }
  21. set
  22. {
  23. foreach (HighlightSelector.Data data in this.datas)
  24. {
  25. if (value == data.type)
  26. {
  27. if (data.button != this.panel.GetSelectButtonObject())
  28. {
  29. this.panel.Select(data.button);
  30. }
  31. return;
  32. }
  33. }
  34. }
  35. }
  36. public bool visible
  37. {
  38. get
  39. {
  40. return base.gameObject.activeSelf;
  41. }
  42. set
  43. {
  44. base.gameObject.SetActive(value);
  45. }
  46. }
  47. private void Awake()
  48. {
  49. this.panel.UpdateChildren();
  50. this.selectItem = HighlightSelector.SelectItem.Eye;
  51. foreach (HighlightSelector.Data data in this.datas)
  52. {
  53. EventDelegate.Add(data.button.onSelect, new EventDelegate.Callback(this.OnClickEvetn));
  54. }
  55. }
  56. private void OnClickEvetn()
  57. {
  58. if (!UIWFSelectButton.current.isSelected)
  59. {
  60. return;
  61. }
  62. if (this.onChangeSelectItem != null)
  63. {
  64. this.onChangeSelectItem(this.selectItem);
  65. }
  66. }
  67. [SerializeField]
  68. private UIWFTabPanel panel;
  69. [SerializeField]
  70. private HighlightSelector.Data[] datas;
  71. public Action<HighlightSelector.SelectItem> onChangeSelectItem;
  72. public enum SelectItem
  73. {
  74. Eye,
  75. EyeR,
  76. EyeL
  77. }
  78. [Serializable]
  79. private struct Data
  80. {
  81. public MPN[] mpns
  82. {
  83. get
  84. {
  85. MPN[] result;
  86. if (this.type == HighlightSelector.SelectItem.Eye)
  87. {
  88. MPN[] array = new MPN[2];
  89. array[0] = MPN.eye_hi;
  90. result = array;
  91. array[1] = MPN.eye_hi_r;
  92. }
  93. else if (this.type == HighlightSelector.SelectItem.EyeR)
  94. {
  95. (result = new MPN[1])[0] = MPN.eye_hi_r;
  96. }
  97. else
  98. {
  99. (result = new MPN[1])[0] = MPN.eye_hi;
  100. }
  101. return result;
  102. }
  103. }
  104. [SerializeField]
  105. public HighlightSelector.SelectItem type;
  106. [SerializeField]
  107. public UIWFTabButton button;
  108. }
  109. }
  110. }