コード例 #1
0
    protected virtual void Update()
    {
        float deltaTime = Time.unscaledDeltaTime;

        m_AudioBG.volume = m_BGVolume;

        if (m_Clip == null)
        {
            if (m_AudioBG.isPlaying)
            {
                m_baseVolume = Mathf.Lerp(m_baseVolume, 0f, deltaTime * 2);
                if (m_baseVolume <= .05f)
                {
                    m_AudioBG.Stop();
                }
            }
            return;
        }
        else
        {
            if (m_AudioBG.clip == m_Clip)
            {
                m_baseVolume = Mathf.Lerp(m_baseVolume, 1f, deltaTime * 2);
            }
            else
            {
                m_baseVolume = Mathf.Lerp(m_baseVolume, 0f, deltaTime * 2);
                if (m_baseVolume <= .05f)
                {
                    m_AudioBG.clip = m_Clip;
                    m_AudioBG.Play();
                }
            }
        }
        TGameObjectPool_Static <int, SFXAudioBase> .TraversalAllActive((SFXAudioBase audio) => { audio.Tick(deltaTime); });
    }
コード例 #2
0
 protected void SetSFXVolume(float volume) => TGameObjectPool_Static <int, SFXAudioBase> .TraversalAllActive((SFXAudioBase audio) => audio.SetVolume(volume));