Beispiel #1
0
    /// <summary>
    /// 音量の設定
    /// </summary>
    public void SetVolume(AudioMixerGroupEnum audioMixerGroupEnum, float setPercentVolume)
    {
        percentVolume = setPercentVolume;
        audioMixer.SetFloat(audioMixerGroupEnum.ToString(), ConvertVolumeFromPercent(setPercentVolume));

        //TODO setPercentVolumeを0で指定した時でも最小値の音量が鳴ってしまうので、ミュート設定を行う
    }
Beispiel #2
0
    /// <summary>
    /// 音量の読み込み
    /// </summary>
    public float GetVolume(AudioMixerGroupEnum audioMixerGroupEnum)
    {
        float volume = 0.0f;

        audioMixer.GetFloat(audioMixerGroupEnum.ToString(), out volume);
        return(ConvertPercentFromVolume(volume));
    }
Beispiel #3
0
    /// <summary>
    /// 切り替え処理
    /// 再生中の音の停止を再生開始を同時に行う
    /// </summary>
    public void ChangeFromDictionary(string fileName, AudioMixerGroupEnum audioMixerGroupEnum, float delay = 0.0f, bool isLoop = false)
    {
        if (!audioSourceDictionary.ContainsKey(fileName))
        {
            Debug.LogWarning("PlayFromDictionary not found filename:" + fileName);
            return;
        }

        AudioMixerGroup targetAudioMixerGroup = audioMixer.FindMatchingGroups(audioMixerGroupEnum.ToString())[0];

        //再生中のすべての音の停止
        Dictionary <string, AudioSource> playingAudioSourceDictionary
            = audioSourceDictionary
              .Where(x => x.Value.outputAudioMixerGroup == targetAudioMixerGroup)
              .Where(x => x.Value.isPlaying == true)
              .ToDictionary(x => x.Key, x => x.Value);

        foreach (var audioSourcePair in playingAudioSourceDictionary)
        {
            StopFromDictionary(audioSourcePair.Key);
        }

        //再生開始
        audioSourceDictionary[fileName].outputAudioMixerGroup = targetAudioMixerGroup;
        audioSourceDictionary[fileName].loop = isLoop;

        StartCoroutine(playCoroutine(audioSourceDictionary[fileName], delay, () =>
        {
        }));
    }
Beispiel #4
0
    //-------------------------------------------------------------------------------------------------
    //単体でロードから再生までを処理する

    /// <summary>
    /// 再生処理
    /// </summary>
    public void PlayWithLoad(string fileName, AudioMixerGroupEnum audioMixerGroupEnum, float delay = 0.0f)
    {
        AudioSource audioSource = loadAudioSource("", fileName);

        audioSource.outputAudioMixerGroup = audioMixer.FindMatchingGroups(audioMixerGroupEnum.ToString())[0];

        StartCoroutine(playCoroutine(audioSource, delay, () =>
        {
            Destroy(audioSource.gameObject);
        }));
    }
Beispiel #5
0
    /// <summary>
    /// ミュートの設定
    /// </summary>
    public void SetMute(AudioMixerGroupEnum audioMixerGroupEnum, bool setIsMute)
    {
        isMute[(int)audioMixerGroupEnum] = setIsMute;

        if (isMute[(int)audioMixerGroupEnum])
        {
            audioMixer.SetFloat(audioMixerGroupEnum.ToString(), -80.0f);
        }
        else
        {
            SetVolume(audioMixerGroupEnum, percentVolume);
        }
    }
Beispiel #6
0
    /// <summary>
    /// 再生処理
    /// </summary>
    public void PlayFromDictionary(string fileName, AudioMixerGroupEnum audioMixerGroupEnum, float delay = 0.0f, bool isLoop = false)
    {
        if (!audioSourceDictionary.ContainsKey(fileName))
        {
            Debug.LogWarning("PlayFromDictionary not found filename:" + fileName);
            return;
        }

        audioSourceDictionary[fileName].outputAudioMixerGroup = audioMixer.FindMatchingGroups(audioMixerGroupEnum.ToString())[0];
        audioSourceDictionary[fileName].loop = isLoop;

        StartCoroutine(playCoroutine(audioSourceDictionary[fileName], delay, () =>
        {
        }));
    }
Beispiel #7
0
 /// <summary>
 /// ミュート状態の取得
 /// </summary>
 public bool GetMute(AudioMixerGroupEnum audioMixerGroupEnum)
 {
     return(isMute[(int)audioMixerGroupEnum]);
 }