示例#1
0
    public void PlaySingle(AudioClip clip, Audio source, MixerGroups mix)
    {
        AudioSource temp = ambientSource;

        if (source == Audio.BACKGROUND)
        {
            temp = ambientSource;
        }
        else if (source == Audio.SOUND_EFFECT)
        {
            temp = efxSource;
        }

        temp.clip = clip;

        switch (mix)
        {
        case MixerGroups.AMBIENT_AUDIO:
            temp.outputAudioMixerGroup = ambientAudio;
            break;

        case MixerGroups.PLAYER_BULLETS:
            temp.outputAudioMixerGroup = playerBullets;
            break;

        case MixerGroups.ENEMY_BULLETS:
            temp.outputAudioMixerGroup = enemyBullets;
            break;
        }



        temp.pitch = Random.Range(lowPitchRange, highPitchRange);
        temp.Play();
    }
示例#2
0
        /// <summary>
        /// グループごとにボリューム設定
        /// </summary>
        /// <param name="group"></param>
        /// <param name="volume"></param>
        public void SetVolume(MixerGroups group, float volume)
        {
            var decibel = 20f * Mathf.Log(volume);

            if (float.IsNegativeInfinity(decibel))
            {
                decibel = -96f;
            }
            audioMixer.SetFloat(group.ToString(), decibel);
        }
示例#3
0
 /// <summary>
 /// Returns the Mixer Group linked with the enum entry provided
 /// </summary>
 public AudioMixerGroup GetMixerGroup(MixerGroups mg)
 {
     return m_mixerGroups[(int)mg];
 }
示例#4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="group"></param>
 /// <returns></returns>
 public float GetVolumeByLinear(MixerGroups group)
 {
     audioMixer.GetFloat(group.ToString(), out var decibel);
     return(Mathf.Pow(10f, decibel / 20f));
 }