using System.Collections; using System.Collections.Generic; using UnityEngine; public class SpeedText : MonoBehaviour { private ShipPathFollower _pathFollower; private TMPro.TextMeshProUGUI _text; private void Awake() { _pathFollower = FindObjectOfType(); _text = GetComponent(); } private void OnEnable() { _pathFollower.OnSpeedChange += UpdateText; } private void OnDisable() { _pathFollower.OnSpeedChange -= UpdateText; } private void UpdateText(float speed) { _text.SetText(speed.ToString()); } }