Toast.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. On = true;
  43. Text.text = str;
  44. Timer = time;
  45. Transform.TweenForCG();
  46. Transform.TweenForVec();
  47. }
  48. }