Esempio n. 1
0
    public static AudioMixerGroup GetMixerGroup(AudioMixer mixer, AudioParamater ap)
    {
        switch (ap)
        {
        case AudioParamater.Ambient:
            return(mixer.FindMatchingGroups(AMBIENTPATH)[0]);

        case AudioParamater.Characters:
            return(mixer.FindMatchingGroups(CHARACTERSPATH)[0]);

        case AudioParamater.Game:
            return(mixer.FindMatchingGroups(GAMEPATH)[0]);

        case AudioParamater.Helper:
            return(mixer.FindMatchingGroups(HELPERPATH)[0]);

        case AudioParamater.Master:
            return(mixer.FindMatchingGroups(MASTERPATH)[0]);

        case AudioParamater.Menu:
            return(mixer.FindMatchingGroups(MENUPATH)[0]);

        case AudioParamater.Music:
            return(mixer.FindMatchingGroups(MUSICPATH)[0]);

        case AudioParamater.Player:
            return(mixer.FindMatchingGroups(PLAYERPATH)[0]);

        default:
            return(null);
        }
    }
Esempio n. 2
0
    public static AudioMixerGroup GetMixerParentGroup(AudioMixer mixer, AudioParamater ap)
    {
        switch (ap)
        {
        case AudioParamater.Ambient:
            return(mixer.FindMatchingGroups(GAMEPATH)[0]);

        case AudioParamater.Characters:
            return(mixer.FindMatchingGroups(GAMEPATH)[0]);

        case AudioParamater.Game:
            return(mixer.FindMatchingGroups(MASTERPATH)[0]);

        case AudioParamater.Helper:
            return(mixer.FindMatchingGroups(GAMEPATH)[0]);

        case AudioParamater.Master:
            return(mixer.FindMatchingGroups(MASTERPATH)[0]);

        case AudioParamater.Menu:
            return(mixer.FindMatchingGroups(MASTERPATH)[0]);

        case AudioParamater.Music:
            return(mixer.FindMatchingGroups(MASTERPATH)[0]);

        case AudioParamater.Player:
            return(mixer.FindMatchingGroups(GAMEPATH)[0]);

        default:
            return(null);
        }
    }
Esempio n. 3
0
    public static string GetVolumeParamater(AudioParamater ap)
    {
        switch (ap)
        {
        case AudioParamater.Ambient:
            return(AMBIENT);

        case AudioParamater.Characters:
            return(CHARACTERS);

        case AudioParamater.Game:
            return(GAME);

        case AudioParamater.Helper:
            return(HELPER);

        case AudioParamater.Master:
            return(MASTER);

        case AudioParamater.Menu:
            return(MENU);

        case AudioParamater.Music:
            return(MUSIC);

        case AudioParamater.Player:
            return(PLAYER);

        default:
            return(null);
        }
    }
Esempio n. 4
0
    /// <summary>
    /// Gets the volume of the given channel.
    /// </summary>
    /// <param name="ap">The audio channel you want to know the volume of</param>
    /// <returns>The currentlevel of the volume</returns>
    public int GetVolume(AudioParamater ap)
    {
        float apVolume;

        audioMixer.GetFloat(Volume.GetVolumeParamater(ap), out apVolume);
        Debug.Log("Audio for " + Volume.GetVolumeParamater(ap) + " is " + apVolume);
        return((int)apVolume);
    }
Esempio n. 5
0
 /// <summary>
 /// Changes the audiosources mixergroup.
 /// </summary>
 /// <param name="ap">The audiochannel you want to change the mixergroup to.</param>
 /// <param name="parent">If you want to change it to it's parent channel.</param>
 private void ChangeAudioMixerGroup(AudioParamater ap, bool parent = false)
 {
     if (parent)
     {
         audioSource.outputAudioMixerGroup = Volume.GetMixerParentGroup(audioMixer, ap);
     }
     else
     {
         audioSource.outputAudioMixerGroup = Volume.GetMixerGroup(audioMixer, ap);
     }
 }
Esempio n. 6
0
    /// <summary>
    /// Sets the volume of a certain audio channel.
    /// </summary>
    /// <param name="ap">The audio channel you want to change</param>
    /// <param name="volume">The volume of the audiochannel</param>
    public void SetVolume(AudioParamater ap, int volume = 80)
    {
        if (volume < 0 || volume > 100)
        {
            throw new System.Exception("The volume value cannot be lower than 0 or higher than 100");
        }

        float apVolume = (float)(volume - 80);

        Debug.Log("Setting volume to:" + apVolume + " on " + Volume.GetVolumeParamater(ap));
        audioMixer.SetFloat(Volume.GetVolumeParamater(ap), apVolume);
    }
Esempio n. 7
0
 /// <summary>
 /// UnPauses all audiosources
 /// </summary>
 /// <param name="ap">The audiochannel</param>
 public void UnPause(AudioParamater ap)
 {
     if (objectSounds.Length > 0)
     {
         foreach (ObjectSound objSound in objectSounds)
         {
             if (objSound.audioChannel == ap)
             {
                 objSound.UnPause();
             }
         }
     }
     else
     {
         Debug.LogWarning("No audio object found!");
     }
 }
Esempio n. 8
0
    /// <summary>
    /// Checks for the current volume and changes it if its different with the volume paramater.
    /// </summary>
    /// <param name="ap">The audio channel you want to check for a volume change</param>
    /// <param name="volume">The volume you want to check on</param>
    /// <returns>The current volume</returns>
    public int SetVolumeOnDifference(AudioParamater ap, int volume = 80)
    {
        if (volume < 0 || volume > 100)
        {
            throw new System.Exception("The volume value cannot be lower than 0 or higher than 100");
        }

        float mixerVolume;

        audioMixer.GetFloat(Volume.GetVolumeParamater(ap), out mixerVolume);

        if ((volume - 80) != (int)mixerVolume)
        {
            SetVolume(ap, volume);
            return(volume);
        }
        else
        {
            return(volume);
        }
    }