using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.VFX; using UnityEngine.UI; public class Loader : MonoBehaviour { public KeyCode NextButton = KeyCode.Space; public KeyCode PrevButton = KeyCode.Return; public KeyCode MenuButton = KeyCode.Escape; public GameObject[] vis; public GameObject menu; private int _current = 0; private int _count; private bool _menu_visible = false; 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().enabled = true; } ToggleMenu(_menu_visible); } void Start() { foreach (GameObject v in vis) { Debug.Log(v.ToString()); } foreach (var device in Microphone.devices) { Debug.Log("Microphone: " + device); } vis[_current].SetActive(true); } void Update() { if (Input.GetKeyDown(NextButton)) { LoadNextVis(); } if (Input.GetKeyDown(MenuButton)) { ToggleMenu(!_menu_visible); } } void LoadNextVis() { vis[_current].SetActive(false); int next = (_current + 1) % _count; _current = next; vis[next].SetActive(true); } void ToggleMenu(bool visible) { if (visible) { menu.GetComponent().enabled = true; } else { menu.GetComponent().enabled = false; } _menu_visible = visible; } }