miepzerino
2023-12-17 3d3813d164cca88294e348f7b13f65b408011cda
Assets/Scripts/SoundManager.cs
@@ -90,6 +90,10 @@
        DontDestroyOnLoad(this);
        PlaySound(SoundName.MusicHappy);
    }
    private void Start()
    {
        LoadAudioSettings();
    }
    public void PlaySound(SoundName _name)
    {
@@ -106,7 +110,7 @@
        }
        //no Sound with name
        Debug.LogWarning("SoundManager: Sounds not found in list: " + _name);
        Debug.LogWarning("AudioManager: Sounds not found in list, add sound to audiomanager: " + _name);
    }
    public void PlaySoundAtPoint(GameObject gObject, SoundName _name)
@@ -129,7 +133,7 @@
        }
        //no Sound with name
        Debug.LogWarning("SoundManager: Sounds not found in list: " + _name);
        Debug.LogWarning("AudioManager: Sounds not found in list, add sound to audiomanager: " + _name);
    }
    private static AudioSource PlayClipAtPointCustom(AudioSource audioSource, Vector3 pos, Sound sound)
@@ -190,7 +194,6 @@
                return;
            }
        }
        Debug.Log("No music was playing!");
        PlaySound(_name);
        return;
    }
@@ -200,46 +203,50 @@
        PlayerPrefs.SetFloat("pVolMaster", volMaster);
        PlayerPrefs.SetFloat("pVolMusic", volMusic);
        PlayerPrefs.SetFloat("pVolSFX", volSFX);
    }
        Debug.Log("Saved Options");
    public void DiscardAudioSettings()
    {
        volMaster = PlayerPrefs.GetFloat("pVolMaster");
        volMusic = PlayerPrefs.GetFloat("pVolMusic");
        volSFX = PlayerPrefs.GetFloat("pVolSFX");
        ChangeMasterVolume(volMaster);
        ChangeSfxVolume(volSFX);
        ChangeMusicVolume(volMusic);
    }
    public void LoadAudioSettings()
    {
        GameObject tempGO = new GameObject("TempSlider");
        if (PlayerPrefs.HasKey("pVolMaster") == false)
        {
            PlayerPrefs.SetFloat("pVolMaster", 0.5f);
            PlayerPrefs.SetFloat("pVolMaster", 1f);
        }
        if (PlayerPrefs.HasKey("pVolMusic") == false)
        {
            PlayerPrefs.SetFloat("pVolMusic", 0.5f);
            PlayerPrefs.SetFloat("pVolMusic", 1f);
        }
        if (PlayerPrefs.HasKey("pVolSFX") == false)
        {
            PlayerPrefs.SetFloat("pVolSFX", 0.5f);
            PlayerPrefs.SetFloat("pVolSFX", 1f);
        }
        volMaster = PlayerPrefs.GetFloat("pVolMaster");
        volMusic = PlayerPrefs.GetFloat("pVolMusic");
        volSFX = PlayerPrefs.GetFloat("pVolSFX");
        if (GameObject.Find("SliderVolume") == false)
        if (GameObject.Find("SliderVolume") == true && GameObject.Find("SliderSFX") == true && GameObject.Find("SliderMusic") == true)
        {
            ChangeMasterVolume(volMaster);
            ChangeSfxVolume(volSFX);
            ChangeMusicVolume(volMusic);
            return;
        }
        GameObject.Find("SliderVolume").GetComponent<Slider>().value = volMaster;
        ChangeMasterVolume(volMaster);
            //ChangeMasterVolume(volMaster);
        GameObject.Find("SliderSFX").GetComponent<Slider>().value = volSFX;
        ChangeSfxVolume(volSFX);
            //ChangeSfxVolume(volSFX);
        GameObject.Find("SliderMusic").GetComponent<Slider>().value = volMusic;
            //ChangeMusicVolume(volMusic);
        }
        ChangeMasterVolume(volMaster);
        ChangeSfxVolume(volSFX);
        ChangeMusicVolume(volMusic);
    }