public SoundSystem(string elementName) : base(elementName) { this.Master.ChangeEvent += (Action <SoundData>)(sd => { MixerVolume.Set(Sound.Mixer, MixerVolume.Names.MasterVolume, sd.GetVolume()); Debug.Log((object)("Master : " + (string)sd)); }); this.BGM.ChangeEvent += (Action <SoundData>)(sd => { MixerVolume.Set(Sound.Mixer, MixerVolume.Names.BGMVolume, sd.GetVolume()); Debug.Log((object)("BGM: " + (string)sd)); }); this.ENV.ChangeEvent += (Action <SoundData>)(sd => { MixerVolume.Set(Sound.Mixer, MixerVolume.Names.ENVVolume, sd.GetVolume()); Debug.Log((object)("ENV: " + (string)sd)); }); this.SystemSE.ChangeEvent += (Action <SoundData>)(sd => { MixerVolume.Set(Sound.Mixer, MixerVolume.Names.SystemSEVolume, sd.GetVolume()); Debug.Log((object)("SystemSE: " + (string)sd)); }); this.GameSE.ChangeEvent += (Action <SoundData>)(sd => { MixerVolume.Set(Sound.Mixer, MixerVolume.Names.GameSEVolume, sd.GetVolume()); Debug.Log((object)("GameSE: " + (string)sd)); }); }
/// <summary> /// Sets the volume for the specified mixer group. /// </summary> /// <param name="mixerGroup">Mixer group to update volume for.</param> /// <param name="volume">Volume to set, from 0-1 (representing 0% and 100%)</param> public void SetVolume(MixerVolume mixerParameter, float volume) { // Save to player prefs PlayerPrefs.SetFloat(mixerParameter.ToString(), volume); PlayerPrefs.Save(); // Get adjusted volume float adjustedVolume = GetLogVolume(volume); // Update the actual volume UpdateVolume(mixerParameter, adjustedVolume); }
public VoiceSystem(string elementName, Dictionary <int, string> dic) : base(elementName) { this.PCM.ChangeEvent += (Action <SoundData>)(sd => { MixerVolume.Set(Manager.Voice.Mixer, MixerVolume.Names.PCMVolume, sd.GetVolume()); Debug.Log((object)("PCM : " + (string)sd)); }); this.chara = dic.ToDictionary <KeyValuePair <int, string>, int, VoiceSystem.Voice>((Func <KeyValuePair <int, string>, int>)(v => v.Key), (Func <KeyValuePair <int, string>, VoiceSystem.Voice>)(v => new VoiceSystem.Voice(v.Value, new SoundData()))); // ISSUE: object of a compiler-generated type is created // ISSUE: object of a compiler-generated type is created this.chara.Select <KeyValuePair <int, VoiceSystem.Voice>, \u003C\u003E__AnonType7 <\u003C\u003E__AnonType6 <int, SoundData> > >((Func <KeyValuePair <int, VoiceSystem.Voice>, \u003C\u003E__AnonType7 <\u003C\u003E__AnonType6 <int, SoundData> > >)(p => new \u003C\u003E__AnonType7 <\u003C\u003E__AnonType6 <int, SoundData> >(new \u003C\u003E__AnonType6 <int, SoundData>(p.Key, p.Value.sound)))).ToList <\u003C\u003E__AnonType7 <\u003C\u003E__AnonType6 <int, SoundData> > >().ForEach((Action <\u003C\u003E__AnonType7 <\u003C\u003E__AnonType6 <int, SoundData> > >)(p => p.sd.sound.ChangeEvent += (Action <SoundData>)(sd => { float volume = sd.GetVolume(); int key = p.sd.Key; Singleton <Manager.Voice> .Instance.GetPlayingList(key).ForEach((Action <AudioSource>)(playing => playing.set_volume(volume))); string str = (string)sd; Debug.Log((object)(string.Format("no:{0}", (object)key) + str)); }))); }
/// <summary> /// Returns the set volume on the game mixer for the specified parameters. /// </summary> /// <param name="mixerParameter">Exposed parameter to read</param> /// <returns></returns> public float GetVolume(MixerVolume mixerParameter) { return(PlayerPrefs.GetFloat(mixerParameter.ToString(), 1.0f)); }
/// <summary> /// Loads the specified volume from PlayerPrefs and applies it to the GameMixer /// </summary> /// <param name="parameter">Specific parameter to fetch</param> private void LoadVolume(MixerVolume parameter) { UpdateVolume(parameter, GetLogVolume(PlayerPrefs.GetFloat(parameter.ToString(), 1.0f))); }
/// <summary> /// Actually updates the volume on the game mixer. /// </summary> /// <param name="mixerParameter">The exposed paramter to update</param> /// <param name="adjustedVolume">The new value</param> private void UpdateVolume(MixerVolume mixerParameter, float adjustedVolume) { gameMixer.SetFloat(mixerParameter.ToString(), adjustedVolume); }