Toast.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEngine.UI;
  4. public class Toast : Regist
  5. {
  6. #region 变量
  7. public static bool On;
  8. public static float Timer;
  9. public static Text Text;
  10. public static Transform Transform;
  11. #endregion
  12. public void FixedUpdate()
  13. {
  14. if (On)
  15. {
  16. Timer -= Time.fixedDeltaTime;
  17. if (Timer <= 0)
  18. {
  19. On = false;
  20. transform.TweenBacCG();
  21. transform.TweenBacVec();
  22. }
  23. }
  24. }
  25. public override void RegistImmed()
  26. {
  27. if (RegistFlag)
  28. {
  29. return;
  30. }
  31. else
  32. {
  33. RegistFlag = true;
  34. }
  35. Text = GetComponentInChildren<Text>();
  36. Transform = transform;
  37. transform.CreateTweenCG(0, 1, 0.25f, false, true, Curve.EaseOutQuad);
  38. transform.CreateTweenVec2D(ManaReso.Get("O_Pos").position, 0.25f, false, false, true, Curve.EaseOutQuad);
  39. }
  40. public static void Show(float time, string str)
  41. {
  42. ManaAudio.PlayClip(Clip.ErrorClip);
  43. On = true;
  44. Text.text = str;
  45. Timer = time;
  46. Transform.TweenForCG();
  47. Transform.TweenForVec();
  48. }
  49. }