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; public GameObject cymbalBackground; [HideInInspector] public GameObject trumpetUI; [HideInInspector] public GameObject tambourineUI; [HideInInspector] public GameObject clarinetUI; [HideInInspector] public GameObject cymbalUI; void Awake() { this.trumpetUI = trumpetBackground.transform.GetChild(0).gameObject; this.tambourineUI = tambourineBackground.transform.GetChild(0).gameObject; this.clarinetUI = clarinetBackground.transform.GetChild(0).gameObject; this.cymbalUI = this.cymbalBackground.transform.GetChild(0).gameObject; } void Start() { this.trumpetBackground.SetActive(StateController.Instance.HasTrumpet()); this.tambourineBackground.SetActive(StateController.Instance.HasTambourine()); this.clarinetBackground.SetActive(StateController.Instance.HasClarinet()); this.cymbalBackground.SetActive(StateController.Instance.HasCymbal()); } 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 ToggleCymbal(bool toggleState) { bool curEnabled = cymbalUI.GetComponent().enabled; if (curEnabled != toggleState) { cymbalUI.GetComponent().enabled = toggleState; } } public void UpdateInstrumentUI() { this.ToggleTrumpet(StateController.Instance.HasTrumpet()); this.ToggleTambourine(StateController.Instance.HasTambourine()); this.ToggleClarinet(StateController.Instance.HasClarinet()); this.ToggleCymbal(StateController.Instance.HasCymbal()); } }