Billboard.cs 823 B

12345678910111213141516171819202122232425262728293031323334353637
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using TMPro;
  5. public class Billboard : MonoBehaviour
  6. {
  7. public TextMeshProUGUI speedText;
  8. private float arrowSpeed;
  9. private float arrowSpeedScale = 1;
  10. public static Billboard ins;
  11. void Awake() {
  12. ins = this;
  13. }
  14. void OnDestroy() {
  15. if (ins == this) ins = null;
  16. }
  17. /**speed m/s */
  18. public void SetArrowSpeed(float value) {
  19. //转km/h
  20. this.arrowSpeed = value * 3600f / 1000f;
  21. }
  22. public void SetArrowSpeedScale(float value) {
  23. this.arrowSpeedScale = value;
  24. }
  25. public void ShowSpeed() {
  26. if (speedText) {
  27. speedText.text = (this.arrowSpeed * this.arrowSpeedScale).ToString($"f{CommonConfig.arrowSpeedPrecision}");
  28. }
  29. }
  30. }