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; }
private void PlayBgmClip(float fadeInTime) { m_ActiveBgmTrack = (m_ActiveBgmTrack + 1) % 2; // Debug.Log("BGM is "+ m_CurrentBgmName); // Debug.Log("play bgm now Active channel is " + m_ActiveBgmTrack ); m_TrackBgm[m_ActiveBgmTrack].enabled = true; if (m_TrackBgm[m_ActiveBgmTrack].clip == null || !m_TrackBgm[m_ActiveBgmTrack].clip.name.Equals(m_CurrentBgmName)) { //Debug.Log("reload!!!!!"); AudioClip clip = null; if (m_bIsSong) { clip = Resources.Load("Sound/Song/" + m_CurrentBgmName) as AudioClip; } else { clip = Resources.Load("Sound/Bgm/" + m_CurrentBgmName) as AudioClip; } m_TrackBgm[m_ActiveBgmTrack].clip = clip; } m_TrackBgm[m_ActiveBgmTrack].volume = 0.011f; m_TrackBgm[m_ActiveBgmTrack].Play(); TweenVolume tv = TweenVolume.Begin(m_TrackBgm[m_ActiveBgmTrack].gameObject, fadeInTime, (float)m_CurrentBgmVol / 100.0f); tv.eventReceiver = gameObject; tv.callWhenFinished = "PlayBgmFadeEnd"; }
private void PlayBgmClip(string bgmName, float fadeInTime, bool loopBgm = true, bool willRest = false) { AudioSource currentAs; if (willRest) { currentAs = m_TrackBgmNRest; m_CurrentBgmNRestName = bgmName; } else { m_ActiveBgmTrack = (m_ActiveBgmTrack + 1) % 2; currentAs = m_TrackBgm[m_ActiveBgmTrack]; m_CurrentBgmName = bgmName; } AudioClip clip = Resources.Load(StringBuilderTool.ToInfoString("Sound/Bgm/", bgmName)) as AudioClip; currentAs.enabled = true; currentAs.clip = clip; currentAs.volume = 0.011f; currentAs.loop = loopBgm; currentAs.Play(); TweenVolume tv = TweenVolume.Begin(currentAs.gameObject, fadeInTime, (float)m_CurrentBgmVol / 100.0f); tv.eventReceiver = gameObject; tv.callWhenFinished = "PlayBgmFadeEnd"; }
void Start() { //GameManager.Instance.DidBossCome += OnBossCome; //GameManager.Instance.DidBossDie += OnAllBossDie; audio.clip = Music0; audio.loop = true; audio.volume = 0.001f; audio.Play(); TweenVolume.Begin(gameObject, 1f, 1f).delay = 0.5f; }
public void StopBgm(float fadeOutTime = 0.5f) { if (m_TrackBgm[m_ActiveBgmTrack].isPlaying) { m_BgmStopped = true; m_StoppingFadeFlg = true; TweenVolume tv = TweenVolume.Begin(m_TrackBgm[m_ActiveBgmTrack].gameObject, fadeOutTime, 0); tv.eventReceiver = gameObject; tv.callWhenFinished = "StopBgmFadeEnd"; m_LastActiveBgmTrack = m_TrackBgm[m_ActiveBgmTrack]; } }
// 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; } }
static public int Begin_s(IntPtr l) { try { UnityEngine.GameObject a1; checkType(l, 1, out a1); System.Single a2; checkType(l, 2, out a2); System.Single a3; checkType(l, 3, out a3); var ret = TweenVolume.Begin(a1, a2, a3); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } }
public void PlayBgm(string bgmName, float fadeInTime = 0.2f, float fadeOutTime = 0.5f) { //m_TrackBgm[0] if (bgmName.Equals(m_CurrentBgmName)) { if (!m_StoppingFadeFlg && m_TrackBgm[m_ActiveBgmTrack].isPlaying) { return; } else { PlayBgmClip(fadeInTime); return; } } if (m_TrackBgm[m_ActiveBgmTrack].clip == null) { PlayBgmClip(bgmName, fadeInTime); } else { if (m_TrackBgm[m_ActiveBgmTrack].isPlaying) { m_FadeInTime = fadeInTime; m_CurrentBgmName = bgmName; TweenVolume tv = TweenVolume.Begin(m_TrackBgm[m_ActiveBgmTrack].gameObject, fadeOutTime, 0); tv.eventReceiver = gameObject; tv.callWhenFinished = "LastBgmFadeEnd"; m_LastActiveBgmTrack = m_TrackBgm[m_ActiveBgmTrack]; if (m_CrossFade) { //m_TrackBgm[m_ActiveBgmTrack].Stop(); m_ActiveBgmTrack = (m_ActiveBgmTrack + 1) % 2; PlayBgmClip(m_CurrentBgmName, fadeInTime); } } else { PlayBgmClip(bgmName, fadeInTime); } } }
private void PlayBgmClip(float fadeInTime, bool loopBgm = true) { m_BgmStopped = false; m_ActiveBgmTrack = (m_ActiveBgmTrack + 1) % 2; m_TrackBgm[m_ActiveBgmTrack].enabled = true; if (m_TrackBgm[m_ActiveBgmTrack].clip == null || !m_TrackBgm[m_ActiveBgmTrack].clip.name.Equals(m_CurrentBgmName)) { AudioClip clip = Resources.Load(StringBuilderTool.ToInfoString("Sound/Bgm/", m_CurrentBgmName)) as AudioClip; m_TrackBgm[m_ActiveBgmTrack].clip = clip; } m_TrackBgm[m_ActiveBgmTrack].volume = 0.011f; m_TrackBgm[m_ActiveBgmTrack].loop = loopBgm; m_TrackBgm[m_ActiveBgmTrack].Play(); TweenVolume tv = TweenVolume.Begin(m_TrackBgm[m_ActiveBgmTrack].gameObject, fadeInTime, (float)m_CurrentBgmVol / 100.0f); tv.eventReceiver = gameObject; tv.callWhenFinished = "PlayBgmFadeEnd"; }
/// <summary> /// PlayBgMusic函数只用于加载背景音乐 /// </summary> /// <param name="name"></param> /// <param name="isAutoDestroy"></param> public void PlayBgMusic(string name, bool isAutoDestroy, bool loop, bool isLocal = false) { //Debug.Log("背景音乐:" + name); if (m_bgMusicName.CompareTo(name) != 0) { m_bgMusicName = name; if (m_bgMusic != null) { if (m_setBgMusicTask != null) { m_setBgMusicTask.Stop(); } TweenVolume.Begin(m_bgMusic.gameObject, 1, 0); m_setBgMusicTask = new Task(SetBgMusicDispear(name, isAutoDestroy, loop)); } else { CreatBgMusic(name, isAutoDestroy, loop, isLocal); } } }
void PlayMusic0() { audio.clip = Music0; audio.Play(); TweenVolume.Begin(gameObject, 0.2f, 1f); }
void OnAllBossDie() { TweenVolume.Begin(gameObject, 0.2f, 0f); Invoke("PlayMusic0", 0.2f); }
void OnBossCome() { TweenVolume.Begin(gameObject, 0.2f, 0f); Invoke("PlayMusicBoss", 0.2f); }
public unsafe static long $Invoke0(long instance, long *args) { return(GCHandledObjects.ObjectToGCHandle(TweenVolume.Begin((GameObject)GCHandledObjects.GCHandleToObject(*args), *(float *)(args + 1), *(float *)(args + 2)))); }
private IEnumerator Start() { while (true) { yield return((object)null); if (playingBGMID != requestBGMID) { changingBGM = true; playingBGMID = requestBGMID; LoadObject lo_bgm = null; if (playingBGMID != 0) { ResourceManager.enableCache = false; lo_bgm = new LoadObject(this, RESOURCE_CATEGORY.SOUND_BGM, ResourceName.GetBGM(requestBGMID), false); ResourceManager.enableCache = true; } if (audioSourceBGM != null && audioSourceBGM.get_isPlaying()) { bool is_play_fadeout = true; EventDelegate.Callback OnFinishedCallBack = delegate { ((_003CStart_003Ec__Iterator240) /*Error near IL_00f3: stateMachine*/)._003Cis_play_fadeout_003E__1 = false; }; TweenVolume fadeout = TweenVolume.Begin(this.get_gameObject(), fadeOutTime, 0f); EventDelegate.Add(fadeout.onFinished, OnFinishedCallBack); while (is_play_fadeout) { audioSourceBGM.set_volume(fadeout.value); yield return((object)null); } EventDelegate.Remove(fadeout.onFinished, OnFinishedCallBack); } if (lo_bgm != null) { if (lo_bgm.isLoading) { yield return((object)lo_bgm.Wait(this)); } if (!(lo_bgm.loadedObject != null)) { int num3 = playingBGMID = (requestBGMID = 0); } else { if (audioSourceBGM == null) { audioSourceBGM = this.get_gameObject().AddComponent <AudioSource>(); } if (audioSourceBGM != null) { audioSourceBGM.set_priority(0); audioSourceBGM.set_reverbZoneMix(0f); audioSourceBGM.set_spread(360f); audioSourceBGM.set_spatialBlend(0f); audioSourceBGM.set_outputAudioMixerGroup(mixerGroupBGM); audioSourceBGM.set_loop(m_IsNextBGMLoop); audioSourceBGM.set_enabled(true); audioSourceBGM.set_clip(lo_bgm.loadedObject as AudioClip); audioSourceBGM.set_volume(volumeBGM); audioSourceBGM.Play(0uL); } } } if (playingBGMID == 0 && audioSourceBGM != null) { audioSourceBGM.Stop(); } changingBGM = false; } } }
public void BeginTweenVolume(GameObject go, float duration, float targetVolume) { TweenVolume.Begin(go, duration, targetVolume); }