fix timing menu bug

This commit is contained in:
ntr committed 2023-07-27 00:08:17 +10:00
1 parent 9f6bc4f703
commit 8b0483f637
4 files changed
+29 -5

No files matched your search

+5
View File
@@ -13,6 +13,9 @@ public class MenuControls : MonoBehaviour, SpaceRaceInput.IMenuActions {
MenuUi menuUi;
[SerializeField]
ShipUi shipUi;
SpaceRaceInput input;
bool visible = false;
@@ -47,6 +50,7 @@ public class MenuControls : MonoBehaviour, SpaceRaceInput.IMenuActions {
// take control off the ship
timingDoc.enabled = false;
shipUi.enabled = false;
shipControls.enabled = false;
}
@@ -57,6 +61,7 @@ public class MenuControls : MonoBehaviour, SpaceRaceInput.IMenuActions {
// resume control of the ship
timingDoc.enabled = true;
shipUi.enabled = true;
shipControls.enabled = true;
}
+1 -1
View File
@@ -8,7 +8,7 @@ public class MenuUi : MonoBehaviour {
UIDocument uiDocument;
VisualElement tracks;
void Start() {
void OnEnable() {
uiDocument = GetComponent<UIDocument>();
}
+8 -4
View File
@@ -6,8 +6,7 @@ using UnityEngine;
using UnityEngine.UIElements;
public class ShipUi : MonoBehaviour {
[SerializeField]
UIDocument uiDocument = null;
UIDocument uiDocument;
[SerializeField]
ShipControls ship;
@@ -20,7 +19,12 @@ public class ShipUi : MonoBehaviour {
VisualElement sectors;
VisualElement timeSheet;
void Awake() {
void OnEnable() {
Init();
}
void Init() {
uiDocument = GetComponent<UIDocument>();
speed = uiDocument.rootVisualElement.Q<Label>("speed");
timer = uiDocument.rootVisualElement.Q<Label>("timer");
sectors = uiDocument.rootVisualElement.Q<VisualElement>("sectors");
@@ -30,7 +34,7 @@ public class ShipUi : MonoBehaviour {
void FixedUpdate() {
if (timer == null || speed == null) {
Debug.LogWarning("no speed or timer");
Awake();
Init();
return;
}