diff --git a/Assets/Scripts/UI/PageController.cs b/Assets/Scripts/UI/PageController.cs index 545ff55..68748db 100644 --- a/Assets/Scripts/UI/PageController.cs +++ b/Assets/Scripts/UI/PageController.cs @@ -49,108 +49,43 @@ public class PageController : MonoBehaviour { Debug.Log("=== PageController 初始化开始 ==="); + // 背景音乐 AudioSource + _bgAudioSource = gameObject.AddComponent(); + _bgAudioSource.loop = true; + _bgAudioSource.playOnAwake = false; + // 绑定首页按钮 - if (_btnStart != null) - { - _btnStart.onClick.AddListener(OnStartClicked); - Debug.Log("PageController: _btnStart 绑定成功"); - } - else - Debug.LogError("PageController: _btnStart 未赋值!"); + if (_btnStart != null) { _btnStart.onClick.AddListener(OnStartClicked); Debug.Log("PageController: _btnStart 绑定成功"); } + else Debug.LogError("PageController: _btnStart 未赋值!"); - if (_btnExit != null) - { - _btnExit.onClick.AddListener(OnExitClicked); - Debug.Log("PageController: _btnExit 绑定成功"); - } - else - Debug.LogError("PageController: _btnExit 未赋值!"); + if (_btnExit != null) { _btnExit.onClick.AddListener(OnExitClicked); Debug.Log("PageController: _btnExit 绑定成功"); } + else Debug.LogError("PageController: _btnExit 未赋值!"); - // 绑定模式选择页按钮 - if (_btnBack != null) - { - _btnBack.onClick.AddListener(OnModeBackClicked); - Debug.Log("PageController: _btnBack 绑定成功"); - } - else - Debug.LogError("PageController: _btnBack 未赋值!"); + if (_btnBack != null) { _btnBack.onClick.AddListener(OnModeBackClicked); Debug.Log("PageController: _btnBack 绑定成功"); } + else Debug.LogError("PageController: _btnBack 未赋值!"); - if (_btnPracticeMode != null) - { - _btnPracticeMode.onClick.AddListener(() => OnModeSelected(ExperimentMode.Learn)); - Debug.Log("PageController: _btnPracticeMode 绑定成功"); - } - else - Debug.LogError("PageController: _btnPracticeMode 未赋值!"); + if (_btnPracticeMode != null) { _btnPracticeMode.onClick.AddListener(() => OnModeSelected(ExperimentMode.Learn)); Debug.Log("PageController: _btnPracticeMode 绑定成功"); } + else Debug.LogError("PageController: _btnPracticeMode 未赋值!"); - if (_btnExamMode != null) - { - _btnExamMode.onClick.AddListener(() => OnModeSelected(ExperimentMode.Exam)); - Debug.Log("PageController: _btnExamMode 绑定成功"); - } - else - Debug.LogError("PageController: _btnExamMode 未赋值!"); + if (_btnExamMode != null) { _btnExamMode.onClick.AddListener(() => OnModeSelected(ExperimentMode.Exam)); Debug.Log("PageController: _btnExamMode 绑定成功"); } + else Debug.LogError("PageController: _btnExamMode 未赋值!"); - // 绑定固定方式选择页按钮 —— 自动修复 - if (_btnFixationBack == null && _fixationPanel != null) - { - var btnBack = _fixationPanel.transform.Find("BtnBack"); - if (btnBack != null) - { - _btnFixationBack = btnBack.GetComponent