public void PlaySeAndFadeBgm(string seName) { AudioClip clip = Resources.Load(StringBuilderTool.ToInfoString("Sound/Se/", seName)) as AudioClip; int track = ChooseFreeSeTrack(); m_TrackSEList[track].clip = clip; m_TrackSEList[track].loop = false; m_TrackSEList[track].Play(); m_FadeBgmSeTrk = track; if (clip.length < 0.5f) { //no fade bgm, cause se is too short if (IsBgmPlaying()) { m_TrackBgm[m_ActiveBgmTrack].volume = (float)(m_CurrentBgmVol / 300.0f); } } else { if (IsBgmPlaying()) { TweenVolume.Begin(m_TrackBgm[m_ActiveBgmTrack].gameObject, 0.2f, (float)m_CurrentBgmVol / 300.0f); } } m_Status = E_SND_STAT.STAT_SE_FADE_BGM; }
// Update is called once per frame void Update() { switch (m_Status) { case E_SND_STAT.STAT_NULL: break; case E_SND_STAT.STAT_SE_FADE_BGM: if (!m_TrackSEList[m_FadeBgmSeTrk].isPlaying && !m_BgmStopped) { m_Status = E_SND_STAT.STAT_NULL; TweenVolume.Begin(m_TrackBgm[m_ActiveBgmTrack].gameObject, 0.2f, (float)m_CurrentBgmVol / 100.0f); m_FadeBgmSeTrk = 0; } break; } }
// Update is called once per frame void Update() { switch(m_Status) { case E_SND_STAT.STAT_NULL: break; case E_SND_STAT.STAT_SE_FADE_BGM: if ( !m_TrackSEList[m_FadeBgmSeTrk].isPlaying ) { m_Status = E_SND_STAT.STAT_NULL; TweenVolume.Begin( m_TrackBgm[m_ActiveBgmTrack].gameObject, 0.2f, (float)m_CurrentBgmVol/100.0f ); m_FadeBgmSeTrk = 0; } break; } }
public void PlaySeAndFadeBgm( string seName ) { AudioClip clip = Resources.Load("Sound/Se/"+seName) as AudioClip; int track = ChooseFreeSeTrack(); m_TrackSEList[track].clip = clip; m_TrackSEList[track].loop = false; m_TrackSEList[track].Play(); m_FadeBgmSeTrk = track; if ( clip.length < 0.5f ) { //no fade bgm, cause se is too short if ( IsBgmPlaying() ) { m_TrackBgm[m_ActiveBgmTrack].volume = (float)( m_CurrentBgmVol / 300.0f ); } } else { if ( IsBgmPlaying() ) { TweenVolume.Begin( m_TrackBgm[m_ActiveBgmTrack].gameObject, 0.2f, (float)m_CurrentBgmVol/300.0f ); } } m_Status = E_SND_STAT.STAT_SE_FADE_BGM; }