37 lines
754 B
C#
37 lines
754 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;
|
|
Label shields;
|
|
|
|
void OnEnable() {
|
|
Init();
|
|
}
|
|
|
|
void Init() {
|
|
uiDocument = GetComponent<UIDocument>();
|
|
speed = uiDocument.rootVisualElement.Q<Label>("speed");
|
|
shields = uiDocument.rootVisualElement.Q<Label>("shields");
|
|
}
|
|
|
|
void FixedUpdate() {
|
|
if (speed == null) {
|
|
Debug.LogWarning("no speed");
|
|
Init();
|
|
return;
|
|
}
|
|
|
|
speed.text = $"{ship.Speed():0}";
|
|
shields.text = ship.Shields;
|
|
}
|
|
}
|