blobs
This commit is contained in:
1 parent
a9db3697f1
commit
bee505ff53
29 files changed
+3467
-1637
No files matched your search
+46
-55
@@ -12,87 +12,78 @@ public class Loader : MonoBehaviour {
|
||||
public KeyCode PrevButton = KeyCode.Return;
|
||||
public KeyCode MenuButton = KeyCode.Escape;
|
||||
|
||||
public GameObject[] vis;
|
||||
public GameObject menu;
|
||||
public Text currentVis;
|
||||
public Canvas vfxMenu;
|
||||
|
||||
private int _current = 0;
|
||||
private int _count;
|
||||
|
||||
private bool _menu_visible = false;
|
||||
private static bool menuVisible;
|
||||
private Scene scene;
|
||||
|
||||
void Awake() {
|
||||
vis = GameObject.FindGameObjectsWithTag("VFX");
|
||||
_count = vis.Length;
|
||||
|
||||
foreach (GameObject v in vis) {
|
||||
// all visualisations are active
|
||||
// but their vfx components are disabled in editor
|
||||
v.SetActive(false);
|
||||
v.GetComponent<VisualEffect>().enabled = true;
|
||||
// v.GetComponent<VfxAudioSpectrumDataBinder>().enabled = true;
|
||||
|
||||
// look for a canvas in children
|
||||
// bit sketchy...
|
||||
Canvas v_menu = v.GetComponentInChildren<Canvas>();
|
||||
if (v_menu) v_menu.enabled = false;
|
||||
}
|
||||
|
||||
ToggleMenu(_menu_visible);
|
||||
ToggleMenu(menuVisible);
|
||||
}
|
||||
|
||||
void Start() {
|
||||
foreach (GameObject v in vis) {
|
||||
Debug.Log(v.ToString());
|
||||
}
|
||||
|
||||
foreach (var device in Microphone.devices) {
|
||||
Debug.Log("Microphone: " + device);
|
||||
}
|
||||
|
||||
LoadVis(0);
|
||||
scene = SceneManager.GetActiveScene();
|
||||
currentVis.text = scene.name;
|
||||
// Debug.Log("Active Scene name is: " + scene.name + "\nActive Scene index: " + scene.buildIndex);
|
||||
}
|
||||
|
||||
void Update() {
|
||||
if (Input.GetKeyDown(NextButton)) {
|
||||
// LoadNextVis();
|
||||
SceneManager.LoadSceneAsync("Main 2");
|
||||
NextScene();
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(NextButton)) {
|
||||
PrevScene();
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(MenuButton)) {
|
||||
ToggleMenu(!_menu_visible);
|
||||
ToggleMenu(!menuVisible);
|
||||
}
|
||||
}
|
||||
|
||||
void LoadVis(int i) {
|
||||
_current = i;
|
||||
vis[i].SetActive(true);
|
||||
currentVis.text = vis[i].name;
|
||||
|
||||
// ensure menu is synced on vis change
|
||||
ToggleMenu(_menu_visible);
|
||||
}
|
||||
|
||||
void LoadNextVis() {
|
||||
vis[_current].SetActive(false);
|
||||
int next = (_current + 1) % _count;
|
||||
LoadVis(next);
|
||||
}
|
||||
|
||||
void VisMenuVisible(int i, bool v) {
|
||||
Canvas v_menu = vis[i].GetComponentInChildren<Canvas>();
|
||||
if (v_menu) v_menu.enabled = v;
|
||||
void VfxMenuVisible(bool v) {
|
||||
if (vfxMenu) vfxMenu.enabled = v;
|
||||
}
|
||||
|
||||
void ToggleMenu(bool visible) {
|
||||
if (visible) {
|
||||
menu.GetComponent<Canvas>().enabled = true;
|
||||
VisMenuVisible(_current, true);
|
||||
VfxMenuVisible(true);
|
||||
} else {
|
||||
menu.GetComponent<Canvas>().enabled = false;
|
||||
VisMenuVisible(_current, false);
|
||||
VfxMenuVisible(false);
|
||||
}
|
||||
|
||||
_menu_visible = visible;
|
||||
menuVisible = visible;
|
||||
}
|
||||
|
||||
public void NextScene() {
|
||||
int current = scene.buildIndex;
|
||||
int next = (current + 1) % (SceneManager.sceneCountInBuildSettings);
|
||||
if (next != current) LoadScene(next);
|
||||
}
|
||||
|
||||
public void PrevScene() {
|
||||
int current = scene.buildIndex;
|
||||
int prev = (current - 1);
|
||||
if (prev < 0) prev = SceneManager.sceneCountInBuildSettings - 1;
|
||||
if (prev != current) LoadScene(prev);
|
||||
}
|
||||
|
||||
public void LoadScene(int i) {
|
||||
SceneManager.LoadScene(i);
|
||||
}
|
||||
|
||||
// IEnumerator LoadScene(int i) {
|
||||
// AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(i);
|
||||
|
||||
// // Wait until the asynchronous scene fully loads
|
||||
// while (!asyncLoad.isDone)
|
||||
// {
|
||||
// yield return null;
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user