/// <summary> /// Method used to Play the Background Music that will loop in the game. /// Optional values in the signature of the method allow the customization of the call according to the needs. /// </summary> public static void PlayBackGroundMusic(AudioAssets.LoopedMusicType loopedMusic, float volume = 1, bool shouldLoop = true) { SingleAudioPlayer pooledAudioPlayer = AudioPlayerPoolSystem.Instance.AvailableAudioPlayer(); AudioClip clipToPlay = GetLoopClip(loopedMusic); pooledAudioPlayer.SetAudioClip(clipToPlay, !shouldLoop); pooledAudioPlayer.PlayCurrentAudioClip(volume, shouldLoop); }
/// <summary> /// Method used to Play the Background Music that will loop in the game. /// Additional signatures of the method allow the customization of the call according to the needs. /// </summary> public static void PlayBackGroundMusic(AudioAssets.LoopedMusicType loopedMusic) { SingleAudioPlayer pooledAudioPlayer = AudioPlayerPoolSystem.Instance.AvailableAudioPlayer(); AudioClip clipToPlay = GetLoopClip(loopedMusic); pooledAudioPlayer.SetAudioClip(clipToPlay, false); pooledAudioPlayer.PlayCurrentAudioClip(0.2f, false); }
/// <summary> /// Method used to Play the Sound effects of the game. /// Optional values in the signature of the method allow the customization of the call according to the needs. /// </summary> public static void PlaySoundEffect(AudioAssets.Soundeffects soundeffect, Vector2 position, float volume = 1f) { SingleAudioPlayer pooledAudioPlayer = AudioPlayerPoolSystem.Instance.AvailableAudioPlayer(); AudioClip clipToPlay = GetSoundEffectClip(soundeffect); pooledAudioPlayer.transform.position = position; bool shouldDeactivate = true; pooledAudioPlayer.SetAudioClip(clipToPlay, shouldDeactivate); pooledAudioPlayer.PlayCurrentAudioClip(volume); }