コード例 #1
0
        public void ApplyVolume(String parameter, float valueBetween0And1)
        {
            string persistenceKey = PERSISTENCE_KEY_VOLUME + parameter;

            PlayerPrefs.SetFloat(persistenceKey, valueBetween0And1);
            PlayerPrefs.Save();

            AudioMixerGroupVolume.ApplyVolume(_audioMixer, parameter, valueBetween0And1);
        }
コード例 #2
0
        public float RetrieveVolume(String parameter)
        {
            string persistenceKey = PERSISTENCE_KEY_VOLUME + parameter;

            if (PlayerPrefs.HasKey(persistenceKey))
            {
                return(PlayerPrefs.GetFloat(persistenceKey));
            }

            float volume = AudioMixerGroupVolume.RetrieveVolume(_audioMixer, parameter);

            PlayerPrefs.SetFloat(persistenceKey, volume);
            PlayerPrefs.Save();

            return(volume);
        }
コード例 #3
0
        private void LoadVolume()
        {
            List <AudioMixerGroup> audioMixerGroups = _audioMixer
                                                      .FindMatchingGroups(string.Empty)
                                                      .Where(a => !a.name.Contains("Intern") && a.name != "Reverb")
                                                      .ToList();

            foreach (AudioMixerGroup audioMixerGroup in audioMixerGroups)
            {
                string persistenceKey = PERSISTENCE_KEY_VOLUME + audioMixerGroup.name;

                if (!PlayerPrefs.HasKey(persistenceKey))
                {
                    PlayerPrefs.SetFloat(persistenceKey, AudioMixerGroupVolume.RetrieveVolume(_audioMixer, audioMixerGroup.name));
                    PlayerPrefs.Save();

                    continue;
                }

                ApplyVolume(audioMixerGroup.name, PlayerPrefs.GetFloat(persistenceKey));
            }
        }