public static bool IsMuted(this SoundComponent soundComponent, string soundGroupName)
        {
            if (string.IsNullOrEmpty(soundGroupName))
            {
                Log.Warning("Sound group is invalid.");
                return(true);
            }

            ISoundGroup soundGroup = soundComponent.GetSoundGroup(soundGroupName);

            if (soundGroup == null)
            {
                Log.Warning("Sound group '{0}' is invalid.", soundGroupName);
                return(true);
            }

            return(soundGroup.Mute);
        }
        public static float GetVolume(this SoundComponent soundComponent, string soundGroupName)
        {
            if (string.IsNullOrEmpty(soundGroupName))
            {
                Log.Warning("Sound group is invalid.");
                return(0f);
            }

            ISoundGroup soundGroup = soundComponent.GetSoundGroup(soundGroupName);

            if (soundGroup == null)
            {
                Log.Warning("Sound group '{0}' is invalid.", soundGroupName);
                return(0f);
            }

            return(soundGroup.Volume);
        }
예제 #3
0
    /// <summary>
    /// 设置声音组音量
    /// </summary>
    /// <param name="soundComponent"></param>
    /// <param name="soundGroupName"></param>
    /// <param name="volume"></param>
    public static void SetVolume(this SoundComponent soundComponent, string soundGroupName, float volume)
    {
        if (string.IsNullOrEmpty(soundGroupName))
        {
            Log.Warning("Sound group name is null or empty.");
            return;
        }

        ISoundGroup soundGroup = soundComponent.GetSoundGroup(soundGroupName);

        if (soundGroup == null)
        {
            Log.Warning("Sound group is invalid.");
            return;
        }

        soundGroup.Volume = volume;
        GameManager.Setting.SetFloat(string.Format(Const.SettingKey.SoundGroupVolume, soundGroupName), volume);
        GameManager.Setting.Save();
    }
        public static void Mute(this SoundComponent soundComponent, string soundGroupName, bool mute)
        {
            if (string.IsNullOrEmpty(soundGroupName))
            {
                Log.Warning("Sound group is invalid.");
                return;
            }

            ISoundGroup soundGroup = soundComponent.GetSoundGroup(soundGroupName);

            if (soundGroup == null)
            {
                Log.Warning("Sound group '{0}' is invalid.", soundGroupName);
                return;
            }

            soundGroup.Mute = mute;

            GameEntry.Setting.SetBool(string.Format(Constant.Setting.SoundGroupMuted, soundGroupName), mute);
            GameEntry.Setting.Save();
        }
예제 #5
0
        public static void SetVolume(this SoundComponent soundComponent, string soundGroupName, float volume)
        {
            if (string.IsNullOrEmpty(soundGroupName))
            {
                Log.Warning("Sound group is invalid.");
                return;
            }

            ISoundGroup soundGroup = soundComponent.GetSoundGroup(soundGroupName);

            if (soundGroup == null)
            {
                Log.Warning("Sound group '{0}' is invalid.", soundGroupName);
                return;
            }

            soundGroup.Volume = volume;

            GameEntry.Setting.SetFloat(Utility.Text.Format(Constant.Setting.SoundGroupVolume, soundGroupName), volume);
            GameEntry.Setting.Save();
        }
예제 #6
0
    /// <summary>
    /// 设置声音组是否静音
    /// </summary>
    /// <param name="soundComponent"></param>
    /// <param name="soundGroupName"></param>
    /// <param name="isMute"></param>
    public static void SetMute(this SoundComponent soundComponent, string soundGroupName, bool isMute)
    {
        if (string.IsNullOrEmpty(soundGroupName))
        {
            Log.Warning("Sound group name is null or empty.");
            return;
        }

        ISoundGroup soundGroup = soundComponent.GetSoundGroup(soundGroupName);

        if (soundGroup == null)
        {
            Log.Warning("Sound group is invalid.");
            return;
        }

        soundGroup.Mute = isMute;

        GameManager.Setting.SetBool(string.Format(Const.SettingKey.SoundGroupMuted, soundGroupName), isMute);
        GameManager.Setting.Save();
    }
예제 #7
0
 /// <summary>
 /// 获取指定声音组。
 /// </summary>
 /// <param name="soundGroupName">声音组名称。</param>
 /// <returns>要获取的声音组。</returns>
 public ISoundGroup GetSoundGroup(string soundGroupName)
 {
     return(m_SoundMethods.GetSoundGroup(soundGroupName));
 }