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;