diff --git a/Assets/Scripts/UI/PageController.cs b/Assets/Scripts/UI/PageController.cs index 8496f6e..dfa7ba4 100644 --- a/Assets/Scripts/UI/PageController.cs +++ b/Assets/Scripts/UI/PageController.cs @@ -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(); - _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(); - _bgAudioSource.loop = true; - _bgAudioSource.playOnAwake = false; - if (_experimentBgClip != null) { _bgAudioSource.clip = _experimentBgClip; _bgAudioSource.Play(); Debug.Log("PageController: 播放实验背景音乐"); } - } }