diff --git a/Assets/Scripts/UI/PageController.cs b/Assets/Scripts/UI/PageController.cs index f94aa41..2f9363c 100644 --- a/Assets/Scripts/UI/PageController.cs +++ b/Assets/Scripts/UI/PageController.cs @@ -50,12 +50,15 @@ public class PageController : MonoBehaviour Debug.Log("=== PageController 初始化开始 ==="); // 背景音乐 AudioSource - var mainCam = GameObject.Find("Main Camera"); - if (mainCam != null) { _bgAudioSource = mainCam.GetComponent(); if (_bgAudioSource == null) _bgAudioSource = mainCam.AddComponent(); } - else _bgAudioSource = gameObject.AddComponent(); + var mgr = GameObject.Find("[Managers]"); + if (mgr != null) { _bgAudioSource = mgr.AddComponent(); } + else { _bgAudioSource = gameObject.AddComponent(); } _bgAudioSource.loop = true; _bgAudioSource.playOnAwake = false; _bgAudioSource.spatialBlend = 0f; + // 关掉多余AudioListener(只留Main Camera的) + var cam2 = GameObject.Find("camera2"); if (cam2 != null) { var al = cam2.GetComponent(); if (al != null) al.enabled = false; } + var cam3 = GameObject.Find("camera3"); if (cam3 != null) { var al = cam3.GetComponent(); if (al != null) al.enabled = false; } // 绑定首页按钮 if (_btnStart != null) { _btnStart.onClick.AddListener(OnStartClicked); Debug.Log("PageController: _btnStart 绑定成功"); } @@ -335,11 +338,9 @@ public class PageController : MonoBehaviour _bgAudioSource.spatialBlend = 0f; } _bgAudioSource.enabled = true; _bgAudioSource.clip = _homeBgClip; - _bgAudioSource.volume = 0f; + _bgAudioSource.volume = 0.5f; _bgAudioSource.Play(); - if (_fadeCoroutine != null) StopCoroutine(_fadeCoroutine); - _fadeCoroutine = StartCoroutine(FadeInBg()); - Debug.Log("PageController: 播放首页背景音乐, isPlaying=" + _bgAudioSource.isPlaying + " clip=" + (_bgAudioSource.clip!=null?_bgAudioSource.clip.name:"null")); + Debug.Log("PageController: 播放首页背景音乐 vol=0.5 isPlaying=" + _bgAudioSource.isPlaying + " clip=" + (_bgAudioSource.clip!=null?_bgAudioSource.clip.name:"null")); } private void StopBgMusic()