public void Volume(float value, TypeSound type) { if (this.type == type) { source.volume = value; } }
public void ExecuteAmbient(TypeSound audioAmbient, float fadeoutVolumeSpeed) { if (actualAmbientSound == TypeSound.None) { if (audioAmbient != TypeSound.None) { actualAmbientSound = audioAmbient; ambient.clip = listAudios.Find(audio => audio.name == audioAmbient.ToString()).audioClip; ambient.Play(); } return; } if (actualAmbientSound == audioAmbient && ambient.isPlaying) { return; } if (audioAmbient == TypeSound.None) { actualAmbientSound = TypeSound.None; ambient.Stop(); ambient.clip = null; ExecuteEffect(TypeSound.None); return; } actualAmbientSound = audioAmbient; StartCoroutine(Fadeout(audioAmbient, fadeoutVolumeSpeed)); }
public AudioSource ExecuteEffect(TypeSound audioEffect) { AudioStruct clip = listAudios.Find(audio => audio.name == audioEffect.ToString()); audioSourceCurrent = EffectsFree(); audioSourceCurrent.clip = clip.audioClip; audioSourceCurrent.loop = clip.isLoop; audioSourceCurrent.Play(); return(audioSourceCurrent); }
public void PlaySound(TypeSound typeSound) { if (!IsPlaySound) { return; } AudioClip audioClip = _listDataAudioClipTypeSounds.Find(item => item.Type == typeSound).AudioClip; if (audioClip != null) { _audioSourceSound.PlayOneShot(audioClip); } }
IEnumerator Fadeout(TypeSound audioAmbient, float fadeoutVolumeSpeed) { float vol = ambient.volume; while (ambient.volume > 0.01f) { ambient.volume -= fadeoutVolumeSpeed; yield return(new WaitForSeconds(fadeoutVolumeSpeed)); } ambient.clip = listAudios.Find(audio => audio.name == audioAmbient.ToString()).audioClip; ambient.Play(); ambient.volume = vol; }