|
|
|
|
|
|
|
|
|
|
public class AudioManager : MonoBehaviour |
|
|
|
{ |
|
|
|
[Tooltip ("Amount of sound emitters created on Start")] |
|
|
|
[Tooltip("Amount of sound emitters created on Start")] |
|
|
|
[SerializeField] private int _initialPoolSize = 1; |
|
|
|
[SerializeField] private SoundEmitter _soundEmitterPrefab = default; |
|
|
|
[Tooltip("The SoundManager listens to this event, fired by objects in any scene, to play SFXs")] |
|
|
|
|
|
|
{ |
|
|
|
return group.audioMixer.SetFloat("Volume", NormalizedToMixerValue(volume)); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(group.audioMixer.GetFloat("Volume", out float rawVolume)){ |
|
|
|
volume = MixerValueNormalized(rawVolume); |
|
|
|
return true; |
|
|
|
} |
|
|
|
volume = default; |
|
|
|
return false; |
|
|
|
if (group.audioMixer.GetFloat("Volume", out float rawVolume)) |
|
|
|
{ |
|
|
|
volume = MixerValueNormalized(rawVolume); |
|
|
|
return true; |
|
|
|
} |
|
|
|
volume = default; |
|
|
|
return false; |
|
|
|
return (-(value - 80) / 80) - 1; |
|
|
|
return (-(value - 80) / 80) - 1; |
|
|
|
} |
|
|
|
private static float NormalizedToMixerValue(float normalizedValue) |
|
|
|
{ |
|
|
|
|
|
|
if (soundEmitter != null) |
|
|
|
{ |
|
|
|
soundEmitter.PlaySound(clipsToPlay[i], settings, audioCue.looping, position); |
|
|
|
if(audioCue.looping) |
|
|
|
if (audioCue.looping) |
|
|
|
soundEmitter.OnSoundFinishedPlaying += OnSoundEmitterFinishedPlaying; |
|
|
|
} |
|
|
|
} |
|
|
|