HudTextPlus.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. public class HudTextPlus : MonoBehaviour
  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 Outline Outline
  21. {
  22. get
  23. {
  24. if (Outline_ == null)
  25. {
  26. Outline_ = GetComponent<Outline>();
  27. }
  28. return Outline_;
  29. }
  30. set { Outline_ = value; }
  31. }
  32. public Text Text_;
  33. public Outline Outline_;
  34. public float Speed;
  35. public Vector3 Direction;
  36. #endregion
  37. private void FixedUpdate()
  38. {
  39. transform.position += new Vector3(0, Speed*Time.fixedDeltaTime, 0);
  40. if (Text.color.a <= 0.05f)
  41. {
  42. ManaReso.Save(gameObject);
  43. }
  44. }
  45. public void SetOutline(Color color)
  46. {
  47. Outline.effectColor = color;
  48. }
  49. public void SetOutline(Color color, Vector2 size)
  50. {
  51. Outline.effectColor = color;
  52. Outline.effectDistance = size;
  53. }
  54. public void SetDirection(Vector3 direction)
  55. {
  56. Direction = direction;
  57. }
  58. public void Show(string str, int size, float time, float speed)
  59. {
  60. Text.text = str;
  61. Text.fontSize = size;
  62. Speed = speed;
  63. Tween tween = Text.CreateTweenGra(0, time, false, false, Curve.EaseOutQuad);
  64. tween.StartForward();
  65. }
  66. public void Show(string str, int size, float time, float speed, Color originColor)
  67. {
  68. Text.text = str;
  69. Text.fontSize = size;
  70. Speed = speed;
  71. Text.color = originColor;
  72. Tween tween = Text.CreateTweenGra(0, time, false, false, Curve.EaseOutQuad);
  73. tween.StartForward();
  74. }
  75. public void Show(string str, int size, float time, float speed, Color originColor, Color destColor)
  76. {
  77. Text.text = str;
  78. Text.fontSize = size;
  79. Speed = speed;
  80. Text.color = originColor;
  81. Tween tween = Text.CreateTweenGra(destColor, time, false, false, Curve.EaseOutQuad);
  82. tween.StartForward();
  83. }
  84. }