microphone listener

This commit is contained in:
ntr committed 2022-02-03 16:12:06 +11:00
1 parent 0e3c85bac3
commit 7691417ebd
9 files changed
+1699 -1318

No files matched your search

+72 -48
View File
@@ -1,48 +1,72 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.VFX;
public class Loader : MonoBehaviour {
public KeyCode NextButton = KeyCode.Space;
public KeyCode PrevButton = KeyCode.Return;
public GameObject[] vis;
private int _current = 0;
private int _count;
void Awake() {
vis = GameObject.FindGameObjectsWithTag("VFX");
foreach (GameObject v in vis) {
v.SetActive(false);
v.GetComponent<VisualEffect>().enabled = true;
}
_count = vis.Length;
}
void Start() {
foreach (GameObject v in vis) {
Debug.Log(v.ToString());
}
Debug.Log($"{_current}, {_count}");
vis[_current].SetActive(true);
}
void Update() {
if (Input.GetKeyDown(NextButton)) {
LoadNextVis();
}
}
void LoadNextVis() {
vis[_current].SetActive(false);
int next = (_current + 1) % _count;
_current = next;
vis[next].SetActive(true);
}
}
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<VisualEffect>().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<Canvas>().enabled = true;
} else {
menu.GetComponent<Canvas>().enabled = false;
}
_menu_visible = visible;
}
}