UIWFTabButton.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using System;
  2. using UnityEngine;
  3. public class UIWFTabButton : UIWFSelectButton
  4. {
  5. protected override void OnInit()
  6. {
  7. base.OnInit();
  8. this.backup_defaultColor = base.defaultColor;
  9. this.is_init_color_ = true;
  10. }
  11. protected override void OnClick()
  12. {
  13. if (UIWFTabButton.current == null && this.isEnabled)
  14. {
  15. UIWFTabButton uiwftabButton = UIWFTabButton.current;
  16. UIWFTabButton.current = this;
  17. base.OnClick();
  18. UIWFTabButton.current = uiwftabButton;
  19. }
  20. }
  21. public override void SetSelect(bool is_select)
  22. {
  23. if (!this.mInitDone)
  24. {
  25. this.OnInit();
  26. }
  27. if (!this.isEnabled)
  28. {
  29. return;
  30. }
  31. if (!this.is_init_color_)
  32. {
  33. this.backup_defaultColor = base.defaultColor;
  34. this.is_init_color_ = true;
  35. }
  36. if (is_select)
  37. {
  38. base.defaultColor = new Color(this.hover.r, this.hover.g, this.hover.b, this.hover.a);
  39. this.SetState(UIButtonColor.State.Normal, false);
  40. BoxCollider component = base.gameObject.GetComponent<BoxCollider>();
  41. if (component != null)
  42. {
  43. component.size = Vector3.zero;
  44. }
  45. }
  46. else
  47. {
  48. base.defaultColor = this.backup_defaultColor;
  49. BoxCollider component2 = base.gameObject.GetComponent<BoxCollider>();
  50. if (component2 != null && this.widget_ != null)
  51. {
  52. Vector2 localSize = this.widget_.localSize;
  53. component2.size = new Vector3(localSize.x, localSize.y, 0f);
  54. }
  55. }
  56. base.SetSelect(is_select);
  57. }
  58. [Obsolete("Use UIWFSelectButton.current")]
  59. public new static UIWFTabButton current;
  60. private bool is_init_color_;
  61. protected Color backup_defaultColor;
  62. }