fix: 移除重复的PlayHomeBg/StopBgMusic/PlayExperimentBg定义

This commit is contained in:
yangbear
2026-07-01 20:03:45 +08:00
parent 97b793e8f4
commit b26a6e0fc7
-30
View File
@@ -142,10 +142,6 @@ public class PageController : MonoBehaviour
if (_uiManager != null) _uiManager.enabled = (page == Page.Experiment);
// 背景音乐: 首页播 homeBg, 选固定方式时停, 实验启动时播 experimentBg
if (page == Page.Home) PlayHomeBg();
// 背景音乐控制
if (page == Page.Home) PlayHomeBg();
else if (page != Page.Experiment) StopBgMusic();
}
private void PlayHomeBg()
@@ -377,30 +373,4 @@ public class PageController : MonoBehaviour
private AudioSource _bgAudioSource;
private void PlayHomeBg()
{
if (_bgAudioSource == null) _bgAudioSource = gameObject.AddComponent<AudioSource>();
_bgAudioSource.loop = true;
_bgAudioSource.playOnAwake = false;
if (_homeBgClip != null && _bgAudioSource.clip != _homeBgClip)
{
_bgAudioSource.clip = _homeBgClip;
_bgAudioSource.Play();
Debug.Log("PageController: 播放首页背景音乐");
}
}
private void StopBgMusic()
{
if (_bgAudioSource != null && _bgAudioSource.isPlaying) { _bgAudioSource.Stop(); Debug.Log("PageController: 停止背景音乐"); }
}
private void PlayExperimentBg()
{
StopBgMusic();
if (_bgAudioSource == null) _bgAudioSource = gameObject.AddComponent<AudioSource>();
_bgAudioSource.loop = true;
_bgAudioSource.playOnAwake = false;
if (_experimentBgClip != null) { _bgAudioSource.clip = _experimentBgClip; _bgAudioSource.Play(); Debug.Log("PageController: 播放实验背景音乐"); }
}
}