Bubble.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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 Image Icon;
  11. public static Button Cancel;
  12. public static Button Confirm;
  13. public static Transform Box;
  14. public static Transform Background;
  15. #endregion
  16. public override bool RegistImmed()
  17. {
  18. if (base.RegistImmed())
  19. {
  20. return true;
  21. }
  22. Box = ManaReso.Get("K_Bubble0");
  23. Background = ManaReso.Get("K_Bubble");
  24. Tit = ManaReso.Get<Text>("K_Tit");
  25. Lab = ManaReso.Get<Text>("K_Lab");
  26. Icon = ManaReso.Get<Image>("K_Icon");
  27. Cancel = ManaReso.Get<Button>("K_Cancel");
  28. Confirm = ManaReso.Get<Button>("K_Confirm");
  29. Box.CreateTweenScale(Vector3.zero, Vector3.one, 0.25f, false, true, Curve.EaseOutQuad);
  30. Background.CreateTweenGra(0, 180 / 255f, 0.25f, false, true, Curve.EaseOutQuad, true);
  31. return false;
  32. }
  33. public static void Show(string tit = null, string lab = null, Sprite sprite = null, UnityAction confirmAction = null, UnityAction cancelAction = null)
  34. {
  35. ManaAudio.PlayClip(Clip.BubbleClip);
  36. Box.TweenForScale();
  37. Background.TweenForGra();
  38. if (string.IsNullOrEmpty(tit))
  39. {
  40. Tit.SetActive(false);
  41. }
  42. else
  43. {
  44. Tit.SetActive(true);
  45. Tit.text = tit;
  46. }
  47. if (string.IsNullOrEmpty(lab))
  48. {
  49. Lab.SetActive(false);
  50. }
  51. else
  52. {
  53. Lab.SetActive(true);
  54. Lab.text = lab;
  55. }
  56. if (sprite == null)
  57. {
  58. Icon.SetActive(false);
  59. }
  60. else
  61. {
  62. Icon.SetActive(true);
  63. Icon.sprite = sprite;
  64. }
  65. if (cancelAction == null && confirmAction == null)
  66. {
  67. Cancel.SetActive(false);
  68. Confirm.SetButtonEvent(Close);
  69. }
  70. else
  71. {
  72. Cancel.SetActive(true);
  73. Cancel.SetButtonEvent(Close);
  74. Cancel.AddButtonEvent
  75. (
  76. () =>
  77. {
  78. ManaAudio.PlayClip(Clip.BtnClip);
  79. }
  80. );
  81. if (cancelAction != null)
  82. {
  83. Cancel.AddButtonEvent(cancelAction);
  84. }
  85. Confirm.SetButtonEvent(Close);
  86. Confirm.AddButtonEvent(confirmAction);
  87. Confirm.AddButtonEvent
  88. (
  89. () =>
  90. {
  91. ManaAudio.PlayClip(Clip.BtnClip);
  92. }
  93. );
  94. }
  95. }
  96. public static void Close()
  97. {
  98. Box.TweenBacScale();
  99. Background.TweenBacGra();
  100. ManaAudio.PlayClip(Clip.CloseClip);
  101. }
  102. }