From b26a6e0fc7cb2a4c3a9e677454c1b3f3b7bb0cbc Mon Sep 17 00:00:00 2001 From: yangbear Date: Wed, 1 Jul 2026 20:03:45 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=A7=BB=E9=99=A4=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E7=9A=84PlayHomeBg/StopBgMusic/PlayExperimentBg=E5=AE=9A?= =?UTF-8?q?=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/UI/PageController.cs | 30 ----------------------------- 1 file changed, 30 deletions(-) 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: 播放实验背景音乐"); } - } }