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 Update()
  13. {
  14. if (On)
  15. {
  16. Timer -= Time.deltaTime;
  17. if (Timer <= 0)
  18. {
  19. On = false;
  20. transform.TweenBacCG();
  21. transform.TweenBacVec();
  22. }
  23. }
  24. }
  25. public override bool InitAtOnce()
  26. {
  27. if (base.InitAtOnce())
  28. {
  29. return true;
  30. }
  31. Text = GetComponentInChildren<Text>();
  32. Transform = transform;
  33. transform.CreateTweenCG(0, 1, 0.25f, false, true, Curve.EaseOutQuad);
  34. transform.CreateTweenVec2D(ResourceManager.Get(CanvasLabel.O_Pos).position, 0.25f, false, false, true, Curve.EaseOutQuad);
  35. return false;
  36. }
  37. public static void Show(float time, string str)
  38. {
  39. AudioManager.PlayClip(AudioLabel.Error);
  40. On = true;
  41. Text.text = str;
  42. Timer = time;
  43. Transform.TweenForCG();
  44. Transform.TweenForVec();
  45. }
  46. }