HudText.cs 1.1 KB

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