Bubble.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using UnityEngine.Events;
  4. using System.Collections;
  5. public class Bubble : Regist
  6. {
  7. #region 变量
  8. public static Text Tit;
  9. public static Text Lab;
  10. public static Text Lab1;
  11. public static Text Lab2;
  12. public static Text Lab3;
  13. public static Text NotifyLab;
  14. public static Image Icon;
  15. public static Button Cancel;
  16. public static Button Confirm;
  17. public static Button LinkButton;
  18. public static Transform Box;
  19. public static Transform Background;
  20. #endregion
  21. public override bool InitAtOnce()
  22. {
  23. if (base.InitAtOnce())
  24. {
  25. return true;
  26. }
  27. Box = ResourceManager.Get(CanvasLabel.K_Bubble0);
  28. Background = ResourceManager.Get(CanvasLabel.K_Bubble);
  29. Tit = ResourceManager.Get<Text>(CanvasLabel.K_Tit);
  30. Lab = ResourceManager.Get<Text>(CanvasLabel.K_Lab);
  31. Lab1 = ResourceManager.Get<Text>(CanvasLabel.K_Lab1);
  32. Lab2 = ResourceManager.Get<Text>(CanvasLabel.K_Lab2);
  33. Lab3 = ResourceManager.Get<Text>(CanvasLabel.K_Lab3);
  34. NotifyLab = ResourceManager.Get<Text>(CanvasLabel.K_NotifyLab);
  35. Icon = ResourceManager.Get<Image>(CanvasLabel.K_Icon);
  36. Cancel = ResourceManager.Get<Button>(CanvasLabel.K_Cancel);
  37. Confirm = ResourceManager.Get<Button>(CanvasLabel.K_Confirm);
  38. LinkButton = ResourceManager.Get<Button>(CanvasLabel.K_LinkButton);
  39. Box.CreateTweenScale(Vector3.zero, Vector3.one, 0.25f, false, true, Curve.EaseOutQuad);
  40. Background.CreateTweenGra(0, 180 / 255f, 0.25f, false, true, Curve.EaseOutQuad, true);
  41. return false;
  42. }
  43. public override void FirstInit()
  44. {
  45. LanguageManager.Add(ResourceManager.Get<Text>(CanvasLabel.K_CancelLab), new MulLanStr(LanguageLabel.Common__Cancel));
  46. LanguageManager.Add(ResourceManager.Get<Text>(CanvasLabel.K_ConfirmLab), new MulLanStr(LanguageLabel.Common__Confirm));
  47. }
  48. public static void Show(string tit = null, string lab = null, string notifyLab = null, Sprite sprite = null, UnityAction confirmAction = null, UnityAction cancelAction = null, bool enableCancle = true)
  49. {
  50. Lab1.SetActive(false);
  51. Lab2.SetActive(false);
  52. Lab3.SetActive(false);
  53. LinkButton.SetActive(false);
  54. AudioManager.PlayClip(AudioLabel.Bubble);
  55. Box.TweenForScale();
  56. Background.TweenForGra();
  57. if (string.IsNullOrEmpty(tit))
  58. {
  59. Tit.SetActive(false);
  60. }
  61. else
  62. {
  63. Tit.SetActive(true);
  64. Tit.text = tit;
  65. }
  66. if (string.IsNullOrEmpty(lab))
  67. {
  68. Lab.SetActive(false);
  69. }
  70. else
  71. {
  72. Lab.SetActive(true);
  73. Lab.text = lab;
  74. }
  75. if (string.IsNullOrEmpty(notifyLab))
  76. {
  77. NotifyLab.SetActive(false);
  78. }
  79. else
  80. {
  81. NotifyLab.SetActive(true);
  82. NotifyLab.text = notifyLab;
  83. }
  84. if (sprite == null)
  85. {
  86. Icon.SetActive(false);
  87. }
  88. else
  89. {
  90. Icon.SetActive(true);
  91. Icon.sprite = sprite;
  92. }
  93. if (cancelAction == null && confirmAction == null)
  94. {
  95. Cancel.SetActive(false);
  96. Confirm.SetButtonEvent(Close);
  97. }
  98. else
  99. {
  100. Cancel.SetActive(true);
  101. Cancel.SetButtonEvent(Close);
  102. Cancel.AddButtonEvent
  103. (
  104. () =>
  105. {
  106. AudioManager.PlayClip(AudioLabel.ClickButton);
  107. }
  108. );
  109. if (cancelAction != null)
  110. {
  111. Cancel.AddButtonEvent(cancelAction);
  112. }
  113. else
  114. {
  115. if (!enableCancle)
  116. {
  117. Cancel.SetActive(false);
  118. }
  119. }
  120. Confirm.SetButtonEvent(Close);
  121. Confirm.AddButtonEvent(confirmAction);
  122. Confirm.AddButtonEvent
  123. (
  124. () =>
  125. {
  126. AudioManager.PlayClip(AudioLabel.ClickButton);
  127. }
  128. );
  129. }
  130. }
  131. public static void Close()
  132. {
  133. Box.TweenBacScale();
  134. Background.TweenBacGra();
  135. AudioManager.PlayClip(AudioLabel.Close);
  136. }
  137. }