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; public Text currentVis; 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); } LoadVis(0); } void Update() { if (Input.GetKeyDown(NextButton)) { LoadNextVis(); } if (Input.GetKeyDown(MenuButton)) { ToggleMenu(!_menu_visible); } } void LoadVis(int i) { _current = i; vis[i].SetActive(true); currentVis.text = vis[i].name; } void LoadNextVis() { vis[_current].SetActive(false); int next = (_current + 1) % _count; LoadVis(next); } void ToggleMenu(bool visible) { if (visible) { menu.GetComponent().enabled = true; } else { menu.GetComponent().enabled = false; } _menu_visible = visible; } }