added some basic ui
still work in progress, just a progress commit!
This commit is contained in:
58
Assets/Scripts/GameUIController.cs
Normal file
58
Assets/Scripts/GameUIController.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
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() {
|
||||
trumpetUI = trumpetBackground.transform.GetChild(0).gameObject;
|
||||
tambourineUI = tambourineBackground.transform.GetChild(0).gameObject;
|
||||
clarinetUI = clarinetBackground.transform.GetChild(0).gameObject;
|
||||
|
||||
stateController = GameObject.FindGameObjectWithTag("StateController").GetComponent<StateController>();
|
||||
|
||||
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<Image>().enabled;
|
||||
if (curEnabled != toggleState) {
|
||||
trumpetUI.GetComponent<Image>().enabled = toggleState;
|
||||
}
|
||||
}
|
||||
|
||||
public void ToggleTambourine(bool toggleState) {
|
||||
bool curEnabled = tambourineUI.GetComponent<Image>().enabled;
|
||||
if (curEnabled != toggleState) {
|
||||
tambourineUI.GetComponent<Image>().enabled = toggleState;
|
||||
}
|
||||
}
|
||||
|
||||
public void ToggleClarinet(bool toggleState) {
|
||||
bool curEnabled = clarinetUI.GetComponent<Image>().enabled;
|
||||
if (curEnabled != toggleState) {
|
||||
clarinetUI.GetComponent<Image>().enabled = toggleState;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user