Billboard.cs 756 B

123456789101112131415161718192021222324252627282930313233
  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. /**speed m/s */
  15. public void SetArrowSpeed(float value) {
  16. //转km/h
  17. this.arrowSpeed = value * 3600f / 1000f;
  18. }
  19. public void SetArrowSpeedScale(float value) {
  20. this.arrowSpeedScale = value;
  21. }
  22. public void ShowSpeed() {
  23. if (speedText) {
  24. speedText.text = (this.arrowSpeed * this.arrowSpeedScale).ToString($"f{CommonConfig.arrowSpeedPrecision}");
  25. }
  26. }
  27. }