From fc8c2e606267ca178d68fe182d75649d0991d884 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 1 May 2023 17:30:54 -0700 Subject: [PATCH] ACTUALLY FIXED BROKEN COMMIT pull this one! --- Assets/Scripts/GameUIController.cs | 11 +++++++++-- Assets/Scripts/PlayerBehavior.cs | 7 +++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Assets/Scripts/GameUIController.cs b/Assets/Scripts/GameUIController.cs index 442d892..76a87b1 100644 --- a/Assets/Scripts/GameUIController.cs +++ b/Assets/Scripts/GameUIController.cs @@ -18,12 +18,16 @@ public class GameUIController : MonoBehaviour private StateController stateController; void Start() { + stateController = GameObject.FindGameObjectWithTag("StateController").GetComponent(); + if (stateController == null) { + print("state controller not found"); + } else { + print("yeehaw"); + } trumpetUI = trumpetBackground.transform.GetChild(0).gameObject; tambourineUI = tambourineBackground.transform.GetChild(0).gameObject; clarinetUI = clarinetBackground.transform.GetChild(0).gameObject; - stateController = GameObject.FindGameObjectWithTag("StateController").GetComponent(); - if (!stateController.unlockedTrumpet) { trumpetBackground.SetActive(false); } @@ -57,6 +61,9 @@ public class GameUIController : MonoBehaviour } public void ResetInstrumentUI() { + if (stateController == null) { + print("state controller null"); + } if (stateController.unlockedTrumpet) { ToggleTrumpet(true); } diff --git a/Assets/Scripts/PlayerBehavior.cs b/Assets/Scripts/PlayerBehavior.cs index c402f27..261c631 100644 --- a/Assets/Scripts/PlayerBehavior.cs +++ b/Assets/Scripts/PlayerBehavior.cs @@ -37,13 +37,12 @@ public class PlayerBehavior : MonoBehaviour AudioSource audioSource; - void Start() + void Awake() { // initialize _rb = GetComponent(); stateController = GameObject.Find("StateController").GetComponent(); gameUI = GameObject.FindGameObjectWithTag("GameUICanvas").GetComponent(); - gameUI.ResetInstrumentUI(); audioSource = this.gameObject.GetComponent(); audioSource.clip = footstepSound; @@ -54,6 +53,10 @@ public class PlayerBehavior : MonoBehaviour playerIsAlive = true; } + void Start() { + gameUI.ResetInstrumentUI(); + } + void Update() { unlockedTambourine = stateController.unlockedTambourine;