31 lines
643 B
C#
31 lines
643 B
C#
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<ShipPathFollower>();
|
|
_text = GetComponent<TMPro.TextMeshProUGUI>();
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
_pathFollower.OnSpeedChange += UpdateText;
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
_pathFollower.OnSpeedChange -= UpdateText;
|
|
}
|
|
|
|
private void UpdateText(float speed)
|
|
{
|
|
_text.SetText(speed.ToString());
|
|
}
|
|
}
|