Billboard.cs 547 B

12345678910111213141516171819202122232425
  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. static Billboard ins;
  9. void Awake() {
  10. ins = this;
  11. }
  12. /**speed m/s */
  13. public static void ShowSpeed(float speed) {
  14. //转km/h
  15. speed = speed * 3600f / 1000f;
  16. speed = (float)System.Math.Round((double)speed, 1);
  17. if (ins && ins.speedText) {
  18. ins.speedText.text = speed.ToString();
  19. }
  20. }
  21. }