namespace Photon.Voice.Unity.Demos.DemoVoiceUI { using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; using UnityEngine.Serialization; using UnityEngine.UI; public enum MicType { Unity, Photon, FMOD } public struct MicRef { public readonly MicType MicType; public readonly DeviceInfo Device; public MicRef(MicType micType, DeviceInfo device) { this.MicType = micType; this.Device = device; } public override string ToString() { return string.Format("Mic reference: {0}", this.Device.Name); } } public class MicrophoneSelector : VoiceComponent { public class MicrophoneSelectorEvent: UnityEvent {} public MicrophoneSelectorEvent onValueChanged = new MicrophoneSelectorEvent(); private List micOptions; #pragma warning disable 649 [SerializeField] private Dropdown micDropdown; [SerializeField] private Slider micLevelSlider; [SerializeField] private Recorder recorder; [SerializeField] [FormerlySerializedAs("RefreshButton")] private GameObject refreshButton; private Image fillArea; private Color defaultFillColor = Color.white; private Color speakingFillColor = Color.green; #pragma warning restore 649 private IDeviceEnumerator unityMicEnum; private IDeviceEnumerator photonMicEnum; #if PHOTON_VOICE_FMOD_ENABLE private IDeviceEnumerator fmodMicEnum; // set along with Recorder.InputFactory when switching to FMOD mic and then used for checking if the Recorder.InputFactory is FMOD mic private System.Func fmodInputFactory; #endif protected override void Awake() { base.Awake(); // All enumerators trigger refresh automatically in constructor. unityMicEnum = new Unity.AudioInEnumerator(this.Logger); #if PHOTON_VOICE_FMOD_ENABLE // referenced in SetupMicDropdown() called in photonMicEnum initialization this.fmodMicEnum = new Photon.Voice.FMOD.AudioInEnumerator(FMODUnity.RuntimeManager.CoreSystem, this.Logger); #endif photonMicEnum = Platform.CreateAudioInEnumerator(this.Logger); photonMicEnum.OnReady = () => // refreshes asynchronously on WebGL { this.SetupMicDropdown(); this.SetCurrentValue(); }; this.refreshButton.GetComponentInChildren