using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class GameUIController : MonoBehaviour { [Header("Instruments (backgrounds)")] public GameObject trumpetBackground; public GameObject tambourineBackground; public GameObject clarinetBackground; [HideInInspector] public GameObject trumpetUI; [HideInInspector] public GameObject tambourineUI; [HideInInspector] public GameObject clarinetUI; [Header("Other Objects")] 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; if (!stateController.unlockedTrumpet) { trumpetBackground.SetActive(false); } if (!stateController.unlockedTambourine) { tambourineBackground.SetActive(false); } if (!stateController.unlockedClarinet) { clarinetBackground.SetActive(false); } } public void ToggleTrumpet(bool toggleState) { bool curEnabled = trumpetUI.GetComponent().enabled; if (curEnabled != toggleState) { trumpetUI.GetComponent().enabled = toggleState; } } public void ToggleTambourine(bool toggleState) { bool curEnabled = tambourineUI.GetComponent().enabled; if (curEnabled != toggleState) { tambourineUI.GetComponent().enabled = toggleState; } } public void ToggleClarinet(bool toggleState) { bool curEnabled = clarinetUI.GetComponent().enabled; if (curEnabled != toggleState) { clarinetUI.GetComponent().enabled = toggleState; } } public void ResetInstrumentUI() { if (stateController == null) { print("state controller null"); } if (stateController.unlockedTrumpet) { ToggleTrumpet(true); } if (stateController.unlockedTambourine) { ToggleTambourine(true); } if (stateController.unlockedClarinet) { ToggleClarinet(true); } } }