//Sound Effect public void PlaySFX(AudioClipID audioClipID) { if (!sfxAudioSource.isPlaying) { sfxAudioSource.PlayOneShot(FindAudioClip(audioClipID), sfxVolume); } }
//! BACKGROUND MUSIC (BGM) public void PlayBGM(AudioClipID audioClipID) { bgmAudioSource.clip = FindAudioClip(audioClipID); Debug.Log(audioClipID); bgmAudioSource.volume = bgmVolume; bgmAudioSource.Play(); }
public void PlayLoopingSFXWithFadeIn(AudioClipID audioClipID, float fadeInDuration) { AudioClip clipToPlay = FindAudioClip(audioClipID); if (clipToPlay == null) { return; } for (int i = 0; i < loopingSFXAudioSourceList.Count; i++) { if (loopingSFXAudioSourceList[i].clip == clipToPlay) { if (loopingSFXAudioSourceList[i].isPlaying) { return; } loopingSFXAudioSourceList[i].volume = sfxVolume; StartCoroutine(FadeIn(loopingSFXAudioSourceList[i], clipToPlay, fadeInDuration, sfxVolume)); return; } } AudioSource newInstance = sfxAudioSource.gameObject.AddComponent <AudioSource>(); newInstance.playOnAwake = false; newInstance.loop = true; StartCoroutine(FadeIn(newInstance, clipToPlay, fadeInDuration, sfxVolume)); loopingSFXAudioSourceList.Add(newInstance); }
public void PlayLoopingSFX(AudioClipID audioClipID) { AudioClip clipToPlay = FindAudioClip(audioClipID); if (clipToPlay == null) { return; } for (int i = 0; i < loopingSFXAudioSourceList.Count; i++) { if (loopingSFXAudioSourceList[i].clip == clipToPlay) { if (loopingSFXAudioSourceList[i].isPlaying) { return; } loopingSFXAudioSourceList[i].volume = sfxVolume; loopingSFXAudioSourceList[i].Play(); return; } } AudioSource newInstance = sfxAudioSource.gameObject.AddComponent <AudioSource>(); newInstance.playOnAwake = false; newInstance.clip = clipToPlay; newInstance.volume = sfxVolume; newInstance.loop = true; newInstance.Play(); loopingSFXAudioSourceList.Add(newInstance); }
public void PlayLoopingSFX(AudioClipID audioClipID, GameObject go) { AudioClip clipToPlay = FindAudioClip(audioClipID); AudioSource source = FindAudioSource(go); if (source == null) { AudioSource newInstance = go.AddComponent <AudioSource>(); newInstance.clip = clipToPlay; newInstance.volume = sfxVolume; newInstance.loop = true; newInstance.spatialBlend = 1.0f; //For 3D sounds newInstance.Play(); sfxAudioSourceList3D.Add(newInstance); } else { if (source.clip != clipToPlay) { source.clip = clipToPlay; } if (source.isPlaying) { return; } source.volume = sfxVolume; source.Play(); return; } }
public void PlayLoopingSFX(AudioClipID audioClipID) { AudioClip clipToPlay = FindAudioClip(audioClipID); for (int i = 0; i < sfxAudioSourceList.Count; i++) { if (sfxAudioSourceList[i].clip == clipToPlay) { if (sfxAudioSourceList[i].isPlaying) { return; } sfxAudioSourceList[i].volume = sfxVolume; sfxAudioSourceList[i].Play(); return; } } AudioSource newInstance = gameObject.AddComponent <AudioSource>(); newInstance.clip = clipToPlay; newInstance.volume = sfxVolume; newInstance.loop = true; newInstance.Play(); sfxAudioSourceList.Add(newInstance); }
//! BACKGROUND MUSIC (BGM) public void PlayBGM(AudioClipID audioClipID) { bgmAudioSource.clip = FindAudioClip(audioClipID); bgmAudioSource.volume = bgmVolume; bgmAudioSource.loop = true; bgmAudioSource.Play(); }
//! SOUND EFFECTS (SFX) public void PlaySFX(AudioClipID audioClipID, GameObject go) { AudioSource source = FindAudioSource(go); if (source != null) { source.PlayOneShot(FindAudioClip(audioClipID), sfxVolume); } }
public void FadeInPlayBGM(AudioClipID audioClipID) { if (!bgmAudioSource.isPlaying) { bgmAudioSource.clip = FindAudioClip(audioClipID); bgmAudioSource.loop = true; StartCoroutine(FadeIn(bgmAudioSource, bgmAudioSource.clip, 0.5f, 1f)); } }
AudioClip FindAudioClip(AudioClipID audioClipID) { for (int i = 0; i < audioClipInfoList.Count; i++) { if (audioClipInfoList [i].audioClipID == audioClipID) { return(audioClipInfoList [i].audioCLip); } } return(null); }
AudioClip FindAudioClip(AudioClipID audioID) { for (int i = 0; i < audioClipList.Count; i++) { if (audioClipList[i].audioID == audioID) { return(audioClipList[i].audioClip); } } Debug.Log("Cannot find audioClip : " + audioID); return(null); }
public void ChangePitchLoopingSFX(AudioClipID audioClipID, float value) { AudioClip clipToStop = FindAudioClip(audioClipID); for (int i = 0; i < sfxAudioSourceList.Count; i++) { if (sfxAudioSourceList[i].clip == clipToStop) { sfxAudioSourceList[i].pitch = value; return; } } }
public void PlayBGMWithFadeIn(AudioClipID audioClipID, float fadeInDuration) { AudioClip clipToPlay = FindAudioClip(audioClipID); if (clipToPlay == null) { return; } bgmAudioSource.loop = true; StartCoroutine(FadeIn(bgmAudioSource, clipToPlay, fadeInDuration, bgmVolume)); }
public void StopLoopingSFX(AudioClipID audioClipID) { AudioClip clipToStop = FindAudioClip(audioClipID); for (int i = 0; i < sfxAudioSourceList.Count; i++) { if (sfxAudioSourceList[i].clip == clipToStop) { sfxAudioSourceList[i].Stop(); return; } } }
public void PauseLoopingSFX(AudioClipID audioClipID) { AudioClip clipToPause = FindAudioClip(audioClipID); for (int i = 0; i < sfxAudioSourceList.Count; i++) { if (sfxAudioSourceList[i].clip == clipToPause) { sfxAudioSourceList[i].Pause(); return; } } }
public AudioClip FindSFXClip(AudioClipID audioClipID) { for (int i = 0; i < audioClipInfo.Count; i++) { if (audioClipInfo[i].audioClipID == audioClipID) { return(audioClipInfo[i].audioClip); } } Debug.LogError("Cannot find ID: " + audioClipID); return(null); }
//! BACKGROUND MUSIC (BGM) public void PlayBGM(AudioClipID audioClipID) { AudioClip clipToPlay = FindAudioClip(audioClipID); if (clipToPlay == null) { return; } bgmAudioSource.clip = clipToPlay; bgmAudioSource.volume = bgmVolume; bgmAudioSource.loop = true; bgmAudioSource.Play(); }
public AudioClip FindAudioClip(AudioClipID audioClipID) { for (int i = 0; i < audioClipInfoList.Count; i++) { if (audioClipInfoList[i].audioClipID == audioClipID) { return(audioClipInfoList[i].audioClip); } } Debug.LogError("Cannot Find Audio Clip : " + audioClipID); 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 StopLoopingSFX(AudioClipID audioClipID, GameObject go) { AudioClip clipToStop = FindAudioClip(audioClipID); AudioSource source = FindAudioSource(go); if (source == null) { return; } if (source.clip == clipToStop) { source.Stop(); } }
public void PauseLoopingSFX(AudioClipID audioClipID, GameObject go) { AudioClip clipToPause = FindAudioClip(audioClipID); AudioSource source = FindAudioSource(go); if (source == null) { return; } if (source.clip == clipToPause) { source.Pause(); } }
public void ChangePitchLoopingSFX(AudioClipID audioClipID, float value, GameObject go) { AudioClip clipToChange = FindAudioClip(audioClipID); AudioSource source = FindAudioSource(go); if (source == null) { return; } if (source.clip == clipToChange) { source.pitch = value; } }
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 StopLoopingSFX(AudioClipID audioClipID) { AudioClip clipToStop = FindAudioClip(audioClipID); if (clipToStop == null) { return; } for (int i = 0; i < loopingSFXAudioSourceList.Count; i++) { if (loopingSFXAudioSourceList[i].clip == clipToStop) { loopingSFXAudioSourceList[i].Stop(); return; } } }
public void PauseLoopingSFX(AudioClipID audioClipID) { AudioClip clipToPause = FindAudioClip(audioClipID); if (clipToPause == null) { return; } for (int i = 0; i < loopingSFXAudioSourceList.Count; i++) { if (loopingSFXAudioSourceList[i].clip == clipToPause) { loopingSFXAudioSourceList[i].Pause(); return; } } }
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(); } }
public void FadeInPlayBGM(AudioClipID audioClipID) { if (!bgmAudioSource.isPlaying) { bgmAudioSource.clip = FindAudioClip(audioClipID); StopCoroutine("FadeInBGMRoutine"); StartCoroutine("FadeInBGMRoutine"); Debug.Log(bgmVolume); bgmAudioSource.loop = true; bgmAudioSource.Play(); } /*if(!bgmAudioSource.isPlaying) * { * bgmAudioSource.clip = FindAudioClip(audioClipID); * StartCoroutine(FadeIn(bgmAudioSource, bgmAudioSource.clip, 0.5f, 1f)); * } */ }
public void PlayBGM(AudioClipID audioClipID) { /*if(!bgmAudioSource.isPlaying) * { * bgmAudioSource.clip = FindAudioClip(audioClipID); * bgmAudioSource.volume = bgmVolume; * bgmAudioSource.loop = true; * bgmAudioSource.Play(); * }*/ //Baz Version AudioClip clipToPlay = FindAudioClip(audioClipID); if (clipToPlay == null) { return; } bgmAudioSource.clip = clipToPlay; bgmAudioSource.volume = bgmVolume; bgmAudioSource.loop = true; bgmAudioSource.Play(); }
// SFX Functions public void PlaySFX(AudioClipID sfxAudioID) { sfxAudioSource.volume = bgmVolume; sfxAudioSource.PlayOneShot(FindAudioClip(sfxAudioID), sfxVolume); }
//! SOUND EFFECTS (SFX) public void PlaySFX(AudioClipID audioClipID) { sfxAudioSource.PlayOneShot(FindAudioClip(audioClipID), sfxVolume / 2.5f); }