AudioSource FindReadyAudioSource(AudioClipInfo audioClipInfo) { for (int i = 0; i < audioClipInfo.audioSource.Count; i++) { if (!audioClipInfo.audioSource[i].isPlaying) { Debug.Log("Found"); return(audioClipInfo.audioSource[i]); } } Debug.Log("No Ready Audio Sources"); return(null); }
public void PlaySFX(AudioClipID audioClipID) { AudioClipInfo clipToPlay = FindAudioClip(audioClipID); if (clipToPlay == null) { return; } AudioSource player = FindReadyAudioSource(clipToPlay); if (player != null) { player.PlayOneShot(clipToPlay.audioClip, sfxVolume); } }
public void PlayBGMWithFadeOutIn(AudioClipID audioClipID, float fadeOutDuration, float fadeInDuration) { AudioClipInfo clipToPlay = FindAudioClip(audioClipID); if (clipToPlay == null) { return; } AudioSource player = FindReadyAudioSource(clipToPlay); if (player != null) { player.loop = true; StartCoroutine(FadeOutIn(player, fadeOutDuration, fadeInDuration, bgmVolume)); } }
public void PlayBGM(AudioClipID audioClipID) { AudioClipInfo clipToPlay = FindAudioClip(audioClipID); if (clipToPlay == null) { return; } AudioSource player = FindReadyAudioSource(clipToPlay); if (player != null) { player.volume = bgmVolume; player.loop = true; player.Play(); } }