HudTextPlus.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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 Mode MoveMode;
  36. public Vector3 Direction;
  37. #endregion
  38. public enum Mode
  39. {
  40. Position,
  41. Direction,
  42. }
  43. public void FixedUpdate()
  44. {
  45. if (MoveMode == Mode.Direction)
  46. {
  47. transform.position += Direction * Speed * Time.fixedDeltaTime;
  48. }
  49. }
  50. public void SetTween(float time, Color origin, Color dest)
  51. {
  52. Tween tween = Text.CreateTweenGra(origin, dest, time, false, false, Curve.EaseOutQuad);
  53. tween.StartForward();
  54. tween.OnForwardFinish = () =>
  55. {
  56. ManaReso.Save(gameObject);
  57. };
  58. }
  59. public void SetOutline(Color color, Vector2 size)
  60. {
  61. Outline.effectColor = color;
  62. Outline.effectDistance = size;
  63. }
  64. public void SetDirection(Vector3 direction)
  65. {
  66. Direction = direction;
  67. }
  68. public void Show(string str, int size, float speed)
  69. {
  70. MoveMode = Mode.Direction;
  71. Outline.enabled = false;
  72. Text.text = str;
  73. Text.color = Color.white;
  74. Text.fontSize = size;
  75. Speed = speed;
  76. Direction = Vector3.up;
  77. }
  78. public void Show(string str, int size, float time, Vector3 dest)
  79. {
  80. MoveMode = Mode.Position;
  81. Outline.enabled = false;
  82. Text.text = str;
  83. Text.color = Color.white;
  84. Text.fontSize = size;
  85. Direction = Vector3.up;
  86. Tween tween = Text.CreateTweenVec2D(dest, time, false, true, true, Curve.EaseOutQuad);
  87. tween.StartForward();
  88. }
  89. public void Show(string str, int size, float time, Vector3 origin, Vector3 dest)
  90. {
  91. MoveMode = Mode.Position;
  92. Outline.enabled = false;
  93. Text.text = str;
  94. Text.fontSize = size;
  95. Direction = Vector3.up;
  96. Tween tween = Text.CreateTweenVec2D(origin, dest, time, false, true, true, Curve.EaseOutQuad);
  97. tween.StartForward();
  98. }
  99. }