Example #1
0
    private void Start()
    {
        if (!PlayerPrefs.HasKey("Sound"))
        {
            PlayerPrefs.SetInt("Sound", 0);
        }

        if (!PlayerPrefs.HasKey("Music"))
        {
            PlayerPrefs.SetInt("Music", 0);
        }

        Sound.mute = PlayerPrefs.GetInt("Sound") == 1 ? true : false;
        Music.mute = PlayerPrefs.GetInt("Music") == 1 ? true : false;

        _toggleMusic.SetValue(!Music.mute);
        _toggleSound.SetValue(!Sound.mute);

        _toggleMusic.OnValueChanged += MusicValueChangedHandler;
        _toggleSound.OnValueChanged += SoundValueChangedHandler;

        _soundPanelButton.onClick.AddListener(SoundPanelHandler);
    }