3using System.Collections;
60 if (voiceOverData ==
null)
62 Debug.LogError(
"Voice over data is not exist");
79 Debug.LogError(
"audio clip not found " + fxName);
84 return audio !=
null ? audio.IsPlaying :
false;
92 public int PlayFX(
string fxName)
98 Debug.LogError(
"audio clip not found " + fxName);
111 public void PlayFX(
string fxName,
bool loop)
117 Debug.LogError(
"audio clip not found " + fxName);
131 public void PlayFX(
string fxName,
float volume,
bool loop)
137 Debug.LogError(
"audio clip not found " + fxName);
152 public int PlaySpatiallyFX(
string fxName,
float volume,
bool loop, Transform sourceTransform)
154 Debug.Log($
"TestAudio PlaySpatiallyFX {fxName}");
159 Debug.LogError(
"voice over info not found " + fxName);
167 if (spatialSoundSettings ==
null)
return -1;
176 audio.RolloffMode = spatialSoundSettings.audioRolloffMode;
177 audio.Max3DDistance = spatialSoundSettings.maxDistance;
178 audio.Min3DDistance = spatialSoundSettings.minDistance;
179 audio.SpatialBlend = 1f;
184 if (voiceOverInfo.UseSpatialSoundSettings)
186 if (voiceOverInfo.spatialSoundSettings !=
null)
187 return voiceOverInfo.spatialSoundSettings;
190 Debug.LogError(
"Can't use SpatialSoundSettings because it is null");
200 Debug.LogError(
"defaultSpatialSoundSettings is null");
228 Debug.LogWarning(
"Fx not found");
245 if (audioInstance !=
null)
247 audioInstance.Pitch = pitch;
256 public void StopFx(
string fxName)
262 Debug.LogError(
"audio clip not found " + fxName);
285 Debug.LogWarning($
"Fx id - {fxId} is not exist");
305 Debug.LogError(
"audio clip not found " + fxName);
331 Debug.LogError(
"audio clip not found " + voiceOver);
394 Name = voiceOverName,
410 Debug.LogError(
"No Audio File");
417 Name = voiceOverName,
431 public void PlayOnceTime(AudioClip clip,
string voiceOverName)
435 Debug.LogError(
"No Audio File");
444 Name = voiceOverName,
461 PlayOnceAudio.Name =
null;
538 Debug.LogWarning(
"Repeatable sound is not exist");
559 Debug.LogWarning(
"PlayOnceAudio sound is not exist");
571 Debug.LogWarning(
"PlayOnceAudio sound is not exist");
583 Debug.Log(
"TestAudio StopAllVoiceOvers");
592 Debug.Log(
"TestAudio StopAllFx");
607 LastPlayedRepeatableAudio.Volume = volume;
609 PlayOnceAudio.Volume = volume;
658 public class RepeatableAudio
660 public string Name {
get;
set; }
void Stop()
Stop playing audio clip.
void SetVolume(float volume)
Sets the audio volume.
Static class responsible for playing and managing audio and sounds.
static int PlayMusic(AudioClip clip)
Play background music.
static void StopAllMusic()
Stop all music playing.
static int PlaySound(AudioClip clip, string name)
static Audio GetSoundAudio(int audioID)
Returns the sound fx Audio that has as its id the audioID if one is found, returns null if no such Au...
static Audio GetAudio(int audioID)
Returns the Audio that has as its id the audioID if one is found, returns null if no such Audio is fo...
static void StopAllSounds()
Stop all sound fx playing.
Main logic for playing fxs and voice overs.
int PlayMusicWithParams(AudioClip clip)
Action RepeatableAudioStopped
void PauseRepeatable()
Pause currently playing repeatable voice over and save its state Stop currently playing repeatable an...
void SetSfxVolume(string name, float volume)
Set sfx volume If the clip is missing from the data, it will return an warning.
int PlaySpatiallyFX(string fxName, float volume, bool loop, Transform sourceTransform)
Play 3d FX by fx name If the clip is missing from the data, it will return an error.
void StopRepeatable()
Stop currently playing repeatable voice over and remove its state Used for hard manual stop without n...
void StopPlaying()
Stop all fxs.
void InitCurrentVoiceOverdata(VoiceOverData voData)
Init current voiceover data.
Coroutine _playRepeatableCoroutine
void StopRepeatableTemporarily()
Temporarily stop currently playing repeatable voice over Stop currently playing repeatable and saving...
void UpdateLastRepeatable(string voiceOverName)
Update last repeatable Used to restore the last played audio.
void MuteRepeatableSound()
Mute repeatable sound volume.
SpatialSoundSettings defaultSpatialSoundSettings
[SerializeField]
RepeatableAudio PlayOnceAudio
Action< string > OnceTimeAudioStopped
void StopFxById(int fxId)
Stop fx by id If the clip is missing from the data, it will return an warning.
void StopOnceTimeTemporarily()
Stop currently playing voice over.
void PlayRepeatable(AudioClip clip, string voiceOverName)
Play repeatable voice over.
void PlayOnceTime(string voiceOverName)
Play once time by voice over name.
void OnAudioStopped(Hellmade.Sound.Audio audio)
void PlayOnceTime(AudioClip clip, string voiceOverName)
Play once time audio clip.
RepeatableAudio LastPlayedRepeatableAudio
bool IsPlaying(string fxName)
If the clip is missing from the data, it will return an error.
int PlayFX(string fxName)
Play FX by fx name.
void PlayLastRepeatable()
Play last played repeatable voice over from the moment it stopped.
void StopAllVoiceOvers()
Stop all voice overs.
void PlayOnlyOneFX(string fxName)
Play fx by name and stop the others that are playing.
SpatialSoundSettings GetSpatialSoundSettings(VoiceOverInfo voiceOverInfo)
void PlayVoice(AudioClip clip)
Play voice over audio clip.
void StopAllFx()
Stop all fxs.
void ConfigureAudioSource(Hellmade.Sound.Audio audio, SpatialSoundSettings spatialSoundSettings)
void PlayRepeatable(string voiceOverName)
Play voice repeating it at a certain time intervals.
VoiceOverInfo GetOverOverData(string voiceOverName)
Get voice over data Info by name If VO data is missing from the data, it will return an error.
void PlayFX(string fxName, bool loop)
Play FX by fx name If the clip is missing from the data, it will return an error.
const float _soundRepeatDelay
void SetSfxPitch(int audioID, float pitch)
Set sfx pitch by audio id.
IEnumerator PlayRepeatableCoroutine()
void StopFx(string fxName)
Stop fx by name If the clip is missing from the data, it will return an error.
VoiceOverData soundsFx
[SerializeField]
void PlayFX(string fxName, float volume, bool loop)
Play FX by fx name If the clip is missing from the data, it will return an error.
VoiceOverData voices
[SerializeField]
Hellmade.Sound.Audio _lastStartedVO
void SetRepeatableSoundVolume(float volume)
Set repeatable sound volume.
void SetSfxVolume(int audioID, float volume)
Set fx volume by audio id.
void PlayVoice(string voiceOver)
Play voice over by id If the clip is missing from the data, it will return an error.
Hellmade.Sound.Audio Audio
AudioRolloffMode audioRolloffMode
Data that stores all information about voice overs.
VoiceOverInfo GetDataVO(string voID)
Get voiceover info by id.
AudioClip GetAudioClipVO(string voID)
Get voiceover audio clip by id.
bool UseSpatialSoundSettings
SpatialSoundSettings spatialSoundSettings