HudText.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System;
  4. using System.Collections;
  5. public class HudText : ObjRoot
  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. private Text _Text;
  21. #endregion
  22. public override void RegistImmed()
  23. {
  24. if (RegistFlag)
  25. {
  26. return;
  27. }
  28. else
  29. {
  30. RegistFlag = true;
  31. }
  32. enabled = true;
  33. }
  34. private void FixedUpdate()
  35. {
  36. transform.position += new Vector3(0, 7.5f*Time.fixedDeltaTime, 0);
  37. Text.SetAlpha(Mathf.Lerp(Text.color.a, 0, Time.fixedDeltaTime*2));
  38. if (Text.color.a <= 0.05f)
  39. {
  40. ManaReso.Save(gameObject);
  41. }
  42. }
  43. public void Show(string str, Color color, int size)
  44. {
  45. Text.text = str;
  46. Text.color = color;
  47. Text.fontSize = size;
  48. }
  49. }