Bubble.cs 2.7 KB

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