HudText.cs 812 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. private void FixedUpdate()
  23. {
  24. transform.position += new Vector3(0, 7.5f*Time.fixedDeltaTime, 0);
  25. Text.SetAlpha(Mathf.Lerp(Text.color.a, 0, Time.fixedDeltaTime*2));
  26. if (Text.color.a <= 0.05f)
  27. {
  28. ManaReso.Save(gameObject);
  29. }
  30. }
  31. public void Show(string str, Color color)
  32. {
  33. Text.text = str;
  34. Text.color = color;
  35. }
  36. }