public void SetTrack(string resourceName, bool fadeTracks = true) { RefreshMusicVolumeFromGameSettings(); bool hasStartingClip = AudioStorage.GetMusicClip(resourceName, true) != null; ResetSourceSettings(); if (fadeTracks) { TryEndCurrentCoroutine(); currentCoroutine = StartCoroutine(FadeTracks(resourceName, musicFadeTime, hasStartingClip)); } else { if (hasStartingClip) { AudioSource.loop = false; AudioSource.clip = AudioStorage.GetMusicClip(resourceName, true); AudioSource.Play(); SetNextClip(AudioStorage.GetMusicClip(resourceName, false)); } else { AudioSource.loop = true; AudioSource.clip = AudioStorage.GetMusicClip(resourceName, false); AudioSource.Play(); } } }
private void Start() { initiallyLooping = AudioSource.loop; SetVolume(GameSettings.singleton.musicVolume); AudioStorage.TryLoadAll(); }
private IEnumerator FadeTracks(string resourceName, float totalFadeTime, bool hasStartingClip) { float singleFadeTime = totalFadeTime / 2; float startVolume = AudioSource.volume; yield return(StartCoroutine(FadeVolume(startVolume, 0, singleFadeTime))); #region Set New Track if (hasStartingClip) { AudioSource.loop = false; AudioSource.clip = AudioStorage.GetMusicClip(resourceName, true); AudioSource.Play(); } else { AudioSource.loop = true; AudioSource.clip = AudioStorage.GetMusicClip(resourceName, false); AudioSource.Play(); } #endregion yield return(StartCoroutine(FadeVolume(0, startVolume, singleFadeTime))); if (hasStartingClip) { SetNextClip(AudioStorage.GetMusicClip(resourceName, false)); } }
public void PlaySound(string resourceName, Action playCompleteAction = null) { AudioClip clip = AudioStorage.GetFXClip(resourceName); if (clip == null) { Debug.LogWarning("Unable to find sound clip - " + resourceName); return; } else { GameObject fxSource = Instantiate(soundFXSourcePrefab); fxSource.GetComponent <SoundFXSourceController>().PlayClip(clip, playCompleteAction); } }
public void PlayPokemonCry(int speciesId, Action playCompleteAction = null) => PlaySound(AudioStorage.GetPokemonCryClipName(speciesId), playCompleteAction);
private void Start() { AudioStorage.TryLoadAll(); }