WFCheckBox.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class WFCheckBox : MonoBehaviour
  5. {
  6. public virtual void Awake()
  7. {
  8. if (this.Button != null)
  9. {
  10. EventDelegate.Add(this.Button.onClick, new EventDelegate.Callback(this.OnClockEvent));
  11. }
  12. if (this.CheckMarkOffObject != null)
  13. {
  14. this.CheckMarkOffObject.SetActive(!this.check);
  15. }
  16. }
  17. protected virtual void OnClockEvent()
  18. {
  19. this.check = !this.check;
  20. for (int i = 0; i < this.onClick.Count; i++)
  21. {
  22. this.onClick[i](this);
  23. }
  24. }
  25. public new bool enabled
  26. {
  27. get
  28. {
  29. return this.Button.isEnabled;
  30. }
  31. set
  32. {
  33. this.Button.isEnabled = value;
  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. public bool check
  48. {
  49. get
  50. {
  51. return this.CheckMarkObject.activeSelf;
  52. }
  53. set
  54. {
  55. this.CheckMarkObject.SetActive(value);
  56. if (this.CheckMarkOffObject != null)
  57. {
  58. this.CheckMarkOffObject.SetActive(!value);
  59. }
  60. }
  61. }
  62. public string text
  63. {
  64. get
  65. {
  66. return (!(this.LabelObject != null)) ? null : this.LabelObject.text;
  67. }
  68. set
  69. {
  70. if (this.LabelObject != null)
  71. {
  72. this.LabelObject.text = value;
  73. }
  74. }
  75. }
  76. public UILabel LabelObject;
  77. public GameObject CheckMarkObject;
  78. public GameObject CheckMarkOffObject;
  79. public UIButton Button;
  80. public List<Action<WFCheckBox>> onClick = new List<Action<WFCheckBox>>();
  81. }