34 lines
634 B
C#
34 lines
634 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
using UnityEngine;
|
|
using UnityEngine.UIElements;
|
|
|
|
public class ControlsUI : MonoBehaviour {
|
|
[SerializeField]
|
|
ShipControls ship;
|
|
|
|
UIDocument uiDocument;
|
|
Label speed;
|
|
|
|
void OnEnable() {
|
|
Init();
|
|
}
|
|
|
|
void Init() {
|
|
uiDocument = GetComponent<UIDocument>();
|
|
speed = uiDocument.rootVisualElement.Q<Label>("speed");
|
|
}
|
|
|
|
void FixedUpdate() {
|
|
if (speed == null) {
|
|
Debug.LogWarning("no speed");
|
|
Init();
|
|
return;
|
|
}
|
|
|
|
speed.text = $"{ship.Speed():0} u/s";
|
|
}
|
|
}
|