fix: 删除Start()中_bgAudioSource初始化+修复PlayExperimentBg调用

This commit is contained in:
yangbear
2026-07-01 22:12:31 +08:00
parent d52a7e86aa
commit c3d1efbe2c
+1 -8
View File
@@ -49,13 +49,6 @@ public class PageController : MonoBehaviour
{
Debug.Log("=== PageController 初始化开始 ===");
// 背景音乐 AudioSource
var mgr = GameObject.Find("[Managers]");
if (mgr != null) { _bgAudioSource = mgr.AddComponent<AudioSource>(); }
else { _bgAudioSource = gameObject.AddComponent<AudioSource>(); }
_bgAudioSource.loop = true;
_bgAudioSource.playOnAwake = false;
_bgAudioSource.spatialBlend = 0f;
// 关掉多余AudioListener(只留Main Camera的)
var cam2 = GameObject.Find("camera2"); if (cam2 != null) { var al = cam2.GetComponent<AudioListener>(); if (al != null) al.enabled = false; }
var cam3 = GameObject.Find("camera3"); if (cam3 != null) { var al = cam3.GetComponent<AudioListener>(); if (al != null) al.enabled = false; }
@@ -274,7 +267,7 @@ public class PageController : MonoBehaviour
{
Debug.Log("PageController: [ActivateExperimentObjects] 显示实验物件");
PlayExperimentBg();
BGMController.PlayExperimentBg();
var allObjects = FindObjectsOfType<GameObject>(true);
foreach (var go in allObjects)