コード例 #1
0
    void Update()
    {
        source.pitch = Mathf.SmoothDamp(source.pitch, targetPitch, ref v1, Time.deltaTime * 10f);

        mixer.GetFloat("Lowpass", out mv);

        mixer.SetFloat("Lowpass", Mathf.SmoothDamp(mv, targetMixer, ref v3, Time.deltaTime * 10f));
    }
コード例 #2
0
    public void SetLevel(float sliderValue)
    {
        float level = Mathf.Log10(sliderValue) * 20;

        Mixer.SetFloat("MusicVol", level);
        if (Mixer.name == "Music")
        {
            Mixer.GetFloat("MusicVol", out PlayerData.musicLevel);
        }
        else if (Mixer.name == "Sound")
        {
            Mixer.GetFloat("MusicVol", out PlayerData.soundLevel);
        }
    }
コード例 #3
0
        public AudioMixerGroupController(AudioMixerGroup mixerGroup)
        {
            this.MixerGroup = mixerGroup;

            float volume;

            if (Mixer.GetFloat(Parameter, out volume))
            {
                volume = AudioCore.DecibelToLinear(volume);

                if (PlayerPrefs.HasKey(Parameter))
                {
                    Volume = PlayerPrefs.GetFloat(Parameter, volume);
                }
                else
                {
                    PlayerPrefs.SetFloat(Parameter, volume);
                }
            }
            else
            {
                throw new InvalidOperationException("A parameter named " + Parameter + " is needed to manipulate the " + MixerGroup.name + " Mixer Group's volume");
            }
        }