miepzerino
2023-12-16 d95020b910bc69ab733f87d5d0238fe2d1164590
Assets/Scripts/SoundManager.cs
@@ -10,7 +10,7 @@
[System.Serializable]
public class Sound
{
    public string name;
    public SoundName name;
    public AudioClip clip;
    public AudioMixerGroupEnum mixerGroup;
@@ -88,11 +88,14 @@
            sounds[i].SetSource(_go.AddComponent<AudioSource>(), audioMixer);
        }
        DontDestroyOnLoad(this);
        PlaySound("MusicHappy");
        PlaySound(SoundName.MusicHappy);
    }
    public void PlaySound(string _name)
    public void PlaySound(SoundName _name)
    {
        if (_name == SoundName.None)
            return;
        for (int i = 0; i < sounds.Length; i++)
        {
            if (sounds[i].name == _name)
@@ -106,8 +109,11 @@
        Debug.LogWarning("SoundManager: Sounds not found in list: " + _name);
    }
    public void PlaySoundAtPoint(GameObject gObject, string _name)
    public void PlaySoundAtPoint(GameObject gObject, SoundName _name)
    {
        if (_name == SoundName.None)
            return;
        gObject.AddComponent<AudioSource>();
        for (int i = 0; i < sounds.Length; i++)
        {
@@ -128,8 +134,6 @@
    private static AudioSource PlayClipAtPointCustom(AudioSource audioSource, Vector3 pos, Sound sound)
    {
        audioSource.volume = sound.volume * (1 + Random.Range(-sound.randomVolume / 2f, sound.randomVolume / 2f));
        audioSource.pitch = sound.pitch * (1 + Random.Range(-sound.randomPitch / 2f, sound.randomPitch / 2f));
        GameObject tempGO = new GameObject("TempAudio"); // create the temp object
        tempGO.transform.position = pos; // set its position
        AudioSource tempASource = tempGO.AddComponent<AudioSource>(); // add an audio source
@@ -142,8 +146,8 @@
        tempASource.playOnAwake = audioSource.playOnAwake;
        tempASource.loop = audioSource.loop;
        tempASource.priority = audioSource.priority;
        tempASource.volume = audioSource.volume;
        tempASource.pitch = audioSource.pitch;
        tempASource.volume = audioSource.volume * (1 + Random.Range(-sound.randomVolume / 2f, sound.randomVolume / 2f));
        tempASource.pitch = audioSource.pitch * (1 + Random.Range(-sound.randomPitch / 2f, sound.randomPitch / 2f));
        tempASource.panStereo = audioSource.panStereo;
        tempASource.spatialBlend = audioSource.spatialBlend;
        tempASource.reverbZoneMix = audioSource.reverbZoneMix;
@@ -175,7 +179,7 @@
        audioMixer.SetFloat("sfxVol", 20f * Mathf.Log10(_volume));
    }
    public void ChangeMusic(string _name)
    public void ChangeMusic(SoundName _name)
    {
        for (int i = 0; i < sounds.Length; i++)
        {