HudText.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System;
  4. using System.Collections;
  5. public class HudText : Regist
  6. {
  7. #region 变量
  8. public Text Text
  9. {
  10. get
  11. {
  12. if (Text_ == null)
  13. {
  14. Text_ = GetComponent<Text>();
  15. }
  16. return Text_;
  17. }
  18. set { Text_ = value; }
  19. }
  20. public Text Text_;
  21. public float Speed;
  22. #endregion
  23. public override void RegistImmed()
  24. {
  25. if (RegistFlag)
  26. {
  27. return;
  28. }
  29. else
  30. {
  31. RegistFlag = true;
  32. }
  33. enabled = true;
  34. }
  35. private void FixedUpdate()
  36. {
  37. transform.position += new Vector3(0, Speed*Time.fixedDeltaTime, 0);
  38. if (Text.color.a <= 0.05f)
  39. {
  40. ManaReso.Save(gameObject);
  41. }
  42. }
  43. public void Show(string str, Color color, int size, float speed, float time)
  44. {
  45. Text.text = str;
  46. Text.color = color;
  47. Text.fontSize = size;
  48. Speed = speed;
  49. Tween tween = Text.CreateTweenGra(0, time, false, false, Curve.EaseOutQuad);
  50. tween.StartForward();
  51. }
  52. }