diff --git a/Assets/Scripts/UI/PageController.cs b/Assets/Scripts/UI/PageController.cs index c161f7c..625ecb9 100644 --- a/Assets/Scripts/UI/PageController.cs +++ b/Assets/Scripts/UI/PageController.cs @@ -53,6 +53,7 @@ public class PageController : MonoBehaviour _bgAudioSource = gameObject.AddComponent(); _bgAudioSource.loop = true; _bgAudioSource.playOnAwake = false; + _bgAudioSource.spatialBlend = 0f; // 绑定首页按钮 if (_btnStart != null) { _btnStart.onClick.AddListener(OnStartClicked); Debug.Log("PageController: _btnStart 绑定成功"); } @@ -328,7 +329,8 @@ public class PageController : MonoBehaviour _homeBgClip = UnityEditor.AssetDatabase.LoadAssetAtPath("Assets/Audio/homeBackgroundMusic.mp3"); #endif if (_homeBgClip == null) return; } - if (_bgAudioSource == null) { _bgAudioSource = gameObject.AddComponent(); _bgAudioSource.loop = true; _bgAudioSource.playOnAwake = false; } + if (_bgAudioSource == null) { _bgAudioSource = gameObject.AddComponent(); _bgAudioSource.loop = true; _bgAudioSource.playOnAwake = false; + _bgAudioSource.spatialBlend = 0f; } _bgAudioSource.enabled = true; _bgAudioSource.clip = _homeBgClip; _bgAudioSource.volume = 0f; @@ -360,7 +362,8 @@ public class PageController : MonoBehaviour _experimentBgClip = UnityEditor.AssetDatabase.LoadAssetAtPath("Assets/Audio/backgroundMusic.mp3"); #endif if (_experimentBgClip == null) return; } - if (_bgAudioSource == null) { _bgAudioSource = gameObject.AddComponent(); _bgAudioSource.loop = true; _bgAudioSource.playOnAwake = false; } + if (_bgAudioSource == null) { _bgAudioSource = gameObject.AddComponent(); _bgAudioSource.loop = true; _bgAudioSource.playOnAwake = false; + _bgAudioSource.spatialBlend = 0f; } _bgAudioSource.enabled = true; _bgAudioSource.clip = _experimentBgClip; _bgAudioSource.volume = 0f; @@ -374,6 +377,7 @@ public class PageController : MonoBehaviour { if (_bgAudioSource == null) yield break; float targetVolume = _bgAudioSource.volume > 0.01f ? _bgAudioSource.volume : 0.5f; + Debug.Log("PageController: FadeInBg 目标音量=" + targetVolume + " spatialBlend=" + _bgAudioSource.spatialBlend); _bgAudioSource.volume = 0f; float elapsed = 0f; while (elapsed < duration)