WfFadeBasic.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. using System;
  2. using UnityEngine;
  3. public class WfFadeBasic : WfFadeBehaviour
  4. {
  5. public override void OnStartedFadeIn()
  6. {
  7. base.OnStartedFadeIn();
  8. if (this.onStartedFadeInAction != null)
  9. {
  10. this.onStartedFadeInAction(this);
  11. }
  12. }
  13. public override void OnStartedFadeOut()
  14. {
  15. base.OnStartedFadeOut();
  16. if (this.onStartedFadeOutAction != null)
  17. {
  18. this.onStartedFadeOutAction(this);
  19. }
  20. }
  21. public override void OnCompleteFadeIn()
  22. {
  23. base.OnCompleteFadeIn();
  24. if (this.onCompleteFadeInAction != null)
  25. {
  26. this.onCompleteFadeInAction(this);
  27. }
  28. }
  29. public override void OnCompleteFadeOut()
  30. {
  31. base.OnCompleteFadeOut();
  32. if (this.onCompleteFadeOutAction != null)
  33. {
  34. this.onCompleteFadeOutAction(this);
  35. }
  36. }
  37. public override void OnUpdateFadeIn(float val)
  38. {
  39. this.alpha = val;
  40. if (this.OnUpdateFadeAlphaAction != null)
  41. {
  42. this.OnUpdateFadeAlphaAction(this);
  43. }
  44. }
  45. public override void OnUpdateFadeOut(float val)
  46. {
  47. this.alpha = val;
  48. if (this.OnUpdateFadeAlphaAction != null)
  49. {
  50. this.OnUpdateFadeAlphaAction(this);
  51. }
  52. }
  53. public virtual float alpha
  54. {
  55. get
  56. {
  57. if (this.targetWidgets != null && 0 < this.targetWidgets.Length)
  58. {
  59. foreach (UIWidget uiwidget in this.targetWidgets)
  60. {
  61. if (uiwidget != null)
  62. {
  63. return uiwidget.alpha;
  64. }
  65. }
  66. }
  67. if (this.targetPanels != null && 0 < this.targetPanels.Length)
  68. {
  69. foreach (UIPanel uipanel in this.targetPanels)
  70. {
  71. if (uipanel != null)
  72. {
  73. return uipanel.alpha;
  74. }
  75. }
  76. }
  77. return 0f;
  78. }
  79. set
  80. {
  81. if (this.targetWidgets != null && 0 < this.targetWidgets.Length)
  82. {
  83. foreach (UIWidget uiwidget in this.targetWidgets)
  84. {
  85. if (uiwidget != null)
  86. {
  87. uiwidget.alpha = value;
  88. }
  89. }
  90. }
  91. if (this.targetPanels != null && 0 < this.targetPanels.Length)
  92. {
  93. foreach (UIPanel uipanel in this.targetPanels)
  94. {
  95. if (uipanel != null)
  96. {
  97. uipanel.alpha = value;
  98. }
  99. }
  100. }
  101. }
  102. }
  103. [SerializeField]
  104. public UIWidget[] targetWidgets;
  105. [SerializeField]
  106. public UIPanel[] targetPanels;
  107. public Action<WfFadeBasic> onStartedFadeInAction;
  108. public Action<WfFadeBasic> onStartedFadeOutAction;
  109. public Action<WfFadeBasic> onCompleteFadeInAction;
  110. public Action<WfFadeBasic> onCompleteFadeOutAction;
  111. public Action<WfFadeBasic> OnUpdateFadeAlphaAction;
  112. }