コード例 #1
0
 public void ToggleMusic()
 {
     if (_isMusicOn)
     {
         PlayerPrefs.SetFloat(PropertiesStorage.GetMusicKey(), AUDIOOFFVALUE);
         _isMusicOn = false;
         Pause();
     }
     else
     {
         PlayerPrefs.SetFloat(PropertiesStorage.GetMusicKey(), AUDIOONVALUE);
         _isMusicOn = true;
         FadeIn();
     }
     PlayerPrefs.Save();
 }
コード例 #2
0
    private void Awake()
    {
        if (musicPlayer == null)
        {
            musicPlayer = this;
        }
        else
        {
            Destroy(gameObject);
        }

        musicKey            = PropertiesStorage.GetMusicKey();
        soundKey            = PropertiesStorage.GetSoundKey();
        musicMixerParameter = PropertiesStorage.GetMusicVolumeMixerParameter();
        soundMixerParameter = PropertiesStorage.GetSoundVolumeMixerParameter();

        DontDestroyOnLoad(transform.gameObject);
        _audioSource = GetComponent <AudioSource>();
    }