Toast.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. Text = GetComponentInChildren<Text>();
  28. Transform = transform;
  29. transform.CreateTweenCG(0, 1, 0.25f, false, true, Curve.EaseOutQuad);
  30. transform.CreateTweenVec2D(ManaReso.Get("O_Pos").position, 0.25f, false, false, true, Curve.EaseOutQuad);
  31. }
  32. public static void Show(float time, string str)
  33. {
  34. ManaAudio.PlayClip(Clip.ErrorClip);
  35. On = true;
  36. Text.text = str;
  37. Timer = time;
  38. Transform.TweenForCG();
  39. Transform.TweenForVec();
  40. }
  41. }