private void AddFilter(AudioSource source) { if (_filter != null) { return; } _filter = GetOrAddComponent <AudioCustomFilter>(source.gameObject); _filter.hideFlags = HideFlags.HideInInspector; _filter.onAudioRead += SetData; source.Play(); }
/// <summary> /// /// </summary> /// <param name="source"></param> public AudioStreamTrack(AudioSource source) : this(Guid.NewGuid().ToString(), new AudioTrackSource()) { if (source == null) { throw new ArgumentNullException("AudioSource argument is null."); } _source = source; _audioCapturer = source.gameObject.AddComponent <AudioCustomFilter>(); _audioCapturer.hideFlags = HideFlags.HideInInspector; _audioCapturer.onAudioRead += SetData; }