public override void Awake() { base.Awake(); rawSpectrum = new float[spectrumSamples]; bandLevels = new float[numberOfBands]; mic = VJMicrophone.GetInstance(); rawData = null; }
public override void Awake() { base.Awake(); rawSpectrum = new float[spectrumSamples]; bandLevels = new float[numberOfBands]; mic = VJMicrophone.GetInstance(); rawData = null; }
public static VJMicrophone GetInstance() { if( !s_instance ) { GameObject go = new GameObject(); go.name = "VJMicrophone"; DontDestroyOnLoad(go); s_instance = go.AddComponent<VJMicrophone>(); var asObj = go.AddComponent<AudioSource>() as AudioSource; asObj.volume = 1.0f; asObj.mute = true; asObj.loop = true; asObj.playOnAwake = false; } return s_instance; }
public static VJMicrophone GetInstance() { if (!s_instance) { GameObject go = new GameObject(); go.name = "VJMicrophone"; DontDestroyOnLoad(go); s_instance = go.AddComponent <VJMicrophone>(); var asObj = go.AddComponent <AudioSource>() as AudioSource; asObj.volume = 1.0f; asObj.mute = true; asObj.loop = true; asObj.playOnAwake = false; } return(s_instance); }
public override void OnInspectorGUI() { VJMicrophone mic = target as VJMicrophone; GUI.changed = false; base.OnInspectorGUI(); string[] deviceNames = new string[Microphone.devices.Length]; deviceNames[0] = ""; int index = 0; for (int i = 0; i < Microphone.devices.Length; i++) { deviceNames[i] = Microphone.devices[i]; if (Microphone.devices[i] == mic.deviceName) { index = i; } } if (mic.deviceName == null || mic.deviceName.Length == 0) { index = 0; } EditorGUILayout.BeginHorizontal(); index = EditorGUILayout.Popup("Mic Device", index, deviceNames); mic.deviceName = deviceNames[index]; PlayerPrefs.SetString("VJMicrophone.deviceName", mic.deviceName); EditorGUILayout.EndHorizontal(); if (GUI.changed) { EditorUtility.SetDirty(target); } }