This commit is contained in:
ntr committed 2023-07-10 00:23:48 +10:00
1 parent ea8c059e9e
commit 7bbc213da2
99 files changed
+5879 -673

No files matched your search

+46
View File
@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;
public class ShipUi : MonoBehaviour {
[SerializeField]
UIDocument uiDocument = null;
[SerializeField]
ShipControls ship;
[SerializeField]
Timing timing;
Label speed;
Label timer;
Label sectors;
VisualElement timeSheet;
void OnEnable() {
speed = uiDocument.rootVisualElement.Q<Label>("speed");
timer = uiDocument.rootVisualElement.Q<Label>("timer");
sectors = uiDocument.rootVisualElement.Q<Label>("sectors");
timeSheet = uiDocument.rootVisualElement.Q<VisualElement>("timeSheet");
}
void FixedUpdate() {
timer.text = $"{timing.sectorTime:0.0}";
speed.text = $"{ship.Speed():0}";
UpdateTimesheet();
}
public void UpdateTimesheet() {
timeSheet.Clear();
foreach (Lap lap in timing.lapTimes) {
Label l = new Label();
l.text = $"{lap}";
timeSheet.Add(l);
}
sectors.text = $"{String.Join(" ", timing.sectorTimes)}";
}
}