5 namespace HKI.Core.Audio
17 [SerializeField]
bool UseMusicAudioPlayer =
true;
19 [SerializeField]
bool UseAmbientAudioPlayer =
true;
21 [SerializeField]
bool UseFxAudioPlayer =
true;
23 [SerializeField]
bool UseUiFxAudioPlayer =
true;
25 [SerializeField]
bool UseVoicesAudioPlayer =
true;
35 GameObject audioListenerGO = null;
50 audioListenerGO =
new GameObject(
"Audio Listener");
52 audioListenerGO.AddComponent<AudioListener>();
53 DontDestroyOnLoad(audioListenerGO);
55 if (UseMusicAudioPlayer)
56 musicAudioPlayer = CreateAudioPlayer(
"Music", MusicAudioPlayerSettings);
58 if(UseAmbientAudioPlayer)
59 ambientAudioPlayer = CreateAudioPlayer(
"Ambient", AmbientAudioPlayerSettings);
62 fxAudioPlayer = CreateAudioPlayer(
"Fx", FxAudioPlayerSettings);
64 if(UseUiFxAudioPlayer)
65 uiFxAudioPlayer = CreateAudioPlayer(
"Ui Fx", UiFxAudioPlayerSettings);
67 if(UseVoicesAudioPlayer)
68 voicesAudioPlayer = CreateAudioPlayer(
"Voices", VoicesAudioPlayerSettings);
74 if(audioListenerGO != null)
75 Destroy(audioListenerGO);
77 if (UseMusicAudioPlayer && musicAudioPlayer != null)
78 Destroy(musicAudioPlayer);
80 if(UseAmbientAudioPlayer && ambientAudioPlayer != null)
81 Destroy(ambientAudioPlayer);
83 if(UseFxAudioPlayer && fxAudioPlayer != null)
84 Destroy(fxAudioPlayer);
86 if(UseUiFxAudioPlayer && uiFxAudioPlayer != null)
87 Destroy(uiFxAudioPlayer);
89 if(UseVoicesAudioPlayer && voicesAudioPlayer != null)
90 Destroy(voicesAudioPlayer);
106 Debug.LogError(
"(AudioSystem) you are trying to play the next sound clip from a playlist with the music audio player but the playlist is null!");
119 Debug.LogError(
"(AudioSystem) you are trying to play the next sound clip from a playlist with the ambient audio player but the playlist is null!");
132 Debug.LogError(
"(AudioSystem) you are trying to play the next sound clip from a playlist with the fx audio player but the playlist is null!");
142 if (playlist != null)
145 Debug.LogError(
"(AudioSystem) you are trying to play the next sound clip from a playlist with the ui fx audio player but the playlist is null!");
155 if (playlist != null)
158 Debug.LogError(
"(AudioSystem) you are trying to play the next sound clip from a playlist with the voices audio player but the playlist is null!");
172 GameObject apGO =
new GameObject(apName);
void PlayNextSoundClipOfPlaylistWithMusicAudioPlayer(Playlist playlist)
This ScriptableObject contains the data of a playlist for the AudioPlayer.
void PlaySoundClipWithVoicesAudioPlayer(SoundClip soundClip)
void PlayNextSoundClipOfPlaylistWithUiFxAudioPlayer(Playlist playlist)
This interface allows the initialization of anything by the Initialzer.
void PlayAudioLocalization(AudioLocalization audioLocalization)
void Setup(AudioPlayerSettings settings)
void PlaySoundClip(SoundClip clip)
SimpleAudioPlayer CreateAudioPlayer(string apName, AudioPlayer.AudioPlayerSettings settings)
void PlayNextSoundClipOfPlaylistWithVoicesAudioPlayer(Playlist playlist)
void PlayAudioLocalization(AudioLocalization audioLocalization)
The AudioSystem is responsble of the creation and access of the general purpose AudioPlayers.
This is a AudioPlayer that can play playlist or SoundClips. It allows to play multiple clips at once ...
void PlaySoundClipWithFxAudioPlayer(SoundClip soundClip)
void PlaySoundClipWithAmbientAudioPlayer(SoundClip soundClip)
void PlayNextSoundClipOfPlaylistWithFxAudioPlayer(Playlist playlist)
void PlaySoundClipWithUiFxAudioPlayer(SoundClip soundClip)
void PlayNextSoundClipOfPlaylistWithAmbientAudioPlayer(Playlist playlist)
This is an extention of the SimpleAudioPlayer. It allows the automatic Setup of the SimpleAudioPlayer...
This is a container ScriptableObject that holds all data required to play a AudioClip.
void PlaySoundClipWithMusicAudioPlayer(SoundClip soundclip)
This ScriptableObject contains as a container for all audio localization information.