HudText.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. enabled = true;
  26. }
  27. private void FixedUpdate()
  28. {
  29. transform.position += new Vector3(0, Speed*Time.fixedDeltaTime, 0);
  30. if (Text.color.a <= 0.05f)
  31. {
  32. ManaReso.Save(gameObject);
  33. }
  34. }
  35. public void Show(string str, Color color, int size, float speed, float time)
  36. {
  37. Text.text = str;
  38. Text.color = color;
  39. Text.fontSize = size;
  40. Speed = speed;
  41. TweenRoot tween = Text.CreateTweenGra(0, time, false, false, Curve.EaseOutQuad);
  42. tween.StartForward();
  43. }
  44. }