ManagerHint.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System.Collections;
  4. public class ManagerHint : MonoBehaviour
  5. {
  6. #region 变量
  7. private Text Hint;
  8. private float StayTimer;
  9. private float _StayTime;
  10. public static ManagerHint Ins;
  11. #endregion
  12. private void Awake()
  13. {
  14. Hint = ManagerResource.Ins.HintLabel;
  15. Ins = this;
  16. _StayTime = 1;
  17. }
  18. private void FixedUpdate()
  19. {
  20. if (Hint.color.a > 0)
  21. {
  22. StayTimer -= Time.fixedDeltaTime;
  23. if (StayTimer > 0)
  24. {
  25. return;
  26. }
  27. Color color = Hint.color;
  28. color.a = Mathf.Lerp(color.a, 0, Time.fixedDeltaTime);
  29. if (color.a <= 0.05f)
  30. {
  31. color.a = 0;
  32. }
  33. Hint.color = color;
  34. }
  35. }
  36. public void Show(string message)
  37. {
  38. Hint.text = message;
  39. Hint.color = new Color(Hint.color.r, Hint.color.g, Hint.color.b, 1);
  40. StayTimer = _StayTime;
  41. }
  42. }