feat: 场景优化 - 清理重复对象、设置Tags/Colliders、重建Canvas UI、连线Inspector引用
- 删除顶层重复的 GameManager/ExperimentController/InteractionSystem/AnimationController - 移除Canvas上的旧 HUDController(保留 UIManager) - 为14个交互定位点设置Tag并添加SphereCollider - 创建12个自定义Tag(InjuryVisual/Swelling/Pain/VitalSigns/Neuro/BandagePos1-3/Ankle/PaddingPos/SplintLeft/SplintRight) - 完全重建Canvas UI子对象结构以匹配 UIManager 脚本 - 连线 ExperimentFlowCoordinator 和 UIManager 的所有 serialized fields - 编译零错误,游戏画面正常显示
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
|
||||
/// <summary>
|
||||
/// UI 中央调度器:引用所有子面板,绑定 StepManager 事件。
|
||||
/// 挂在 Canvas GameObject 上。
|
||||
/// 挂在 Canvas GameObject 上。使用原生 Text(非 TMP)。
|
||||
/// </summary>
|
||||
public class UIManager : MonoBehaviour
|
||||
{
|
||||
@@ -14,15 +13,15 @@ public class UIManager : MonoBehaviour
|
||||
|
||||
[Header("=== 顶部提示栏 ===")]
|
||||
[SerializeField] private GameObject _tipPanel;
|
||||
[SerializeField] private TMP_Text _tipText;
|
||||
[SerializeField] private Text _tipText;
|
||||
|
||||
[Header("=== 详细操作说明(甲方补充 - 学习模式) ===")]
|
||||
[Header("=== 详细操作说明面板 ===")]
|
||||
[SerializeField] private GameObject _detailPanel;
|
||||
[SerializeField] private TMP_Text _detailText;
|
||||
[SerializeField] private Text _detailText;
|
||||
|
||||
[Header("=== 对话气泡 ===")]
|
||||
[SerializeField] private GameObject _dialogueBubble;
|
||||
[SerializeField] private TMP_Text _dialogueText;
|
||||
[SerializeField] private Text _dialogueText;
|
||||
|
||||
[Header("=== 画中画视频 ===")]
|
||||
[SerializeField] private VideoController _videoController;
|
||||
@@ -33,17 +32,17 @@ public class UIManager : MonoBehaviour
|
||||
[SerializeField] private Button _btnNext;
|
||||
[SerializeField] private Button _btnSwitchMode;
|
||||
[SerializeField] private Button _btnReturn;
|
||||
[SerializeField] private TMP_Text _btnSwitchModeLabel;
|
||||
[SerializeField] private Text _btnSwitchModeLabel;
|
||||
|
||||
[Header("=== 底部进度条 ===")]
|
||||
[SerializeField] private Slider _progressBar;
|
||||
[SerializeField] private TMP_Text _progressText;
|
||||
[SerializeField] private Text _progressText;
|
||||
|
||||
[Header("=== 弹窗 ===")]
|
||||
[SerializeField] private ExamPopup _examPopup;
|
||||
[SerializeField] private ScoreDisplay _scoreDisplay;
|
||||
|
||||
[Header("=== 底部主菜单图标 ===")]
|
||||
[Header("=== 底部图标 ===")]
|
||||
[SerializeField] private Button _btnCPR;
|
||||
[SerializeField] private Button _btnFracture;
|
||||
[SerializeField] private Button _btnSprain;
|
||||
@@ -57,6 +56,11 @@ public class UIManager : MonoBehaviour
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (_stepManager == null)
|
||||
_stepManager = FindObjectOfType<StepManager>();
|
||||
if (_interactionSystem == null)
|
||||
_interactionSystem = FindObjectOfType<InteractionSystem>();
|
||||
|
||||
BindEvents();
|
||||
BindButtons();
|
||||
}
|
||||
@@ -78,14 +82,13 @@ public class UIManager : MonoBehaviour
|
||||
|
||||
private void BindButtons()
|
||||
{
|
||||
_btnFullScreen?.onClick.AddListener(ToggleFullScreen);
|
||||
_btnPrevious?.onClick.AddListener(OnPreviousClicked);
|
||||
_btnNext?.onClick.AddListener(OnNextClicked);
|
||||
_btnSwitchMode?.onClick.AddListener(OnSwitchModeClicked);
|
||||
_btnReturn?.onClick.AddListener(OnReturnClicked);
|
||||
|
||||
_btnLimbFixation?.onClick.AddListener(() => _stepManager?.SwitchFixation(FixationMethod.LimbFixation));
|
||||
_btnSplintFixation?.onClick.AddListener(() => _stepManager?.SwitchFixation(FixationMethod.SplintFixation));
|
||||
if (_btnFullScreen) _btnFullScreen.onClick.AddListener(ToggleFullScreen);
|
||||
if (_btnPrevious) _btnPrevious.onClick.AddListener(OnPreviousClicked);
|
||||
if (_btnNext) _btnNext.onClick.AddListener(OnNextClicked);
|
||||
if (_btnSwitchMode) _btnSwitchMode.onClick.AddListener(OnSwitchModeClicked);
|
||||
if (_btnReturn) _btnReturn.onClick.AddListener(OnReturnClicked);
|
||||
if (_btnLimbFixation) _btnLimbFixation.onClick.AddListener(() => _stepManager?.SwitchFixation(FixationMethod.LimbFixation));
|
||||
if (_btnSplintFixation) _btnSplintFixation.onClick.AddListener(() => _stepManager?.SwitchFixation(FixationMethod.SplintFixation));
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -131,17 +134,17 @@ public class UIManager : MonoBehaviour
|
||||
int cur = _stepManager.CurrentStepIndex + 1;
|
||||
int total = _stepManager.TotalSteps;
|
||||
if (_progressBar != null) _progressBar.value = (float)cur / total;
|
||||
if (_progressText != null) _progressText.text = $"{cur}/{total}";
|
||||
if (_progressText != null) _progressText.text = cur + "/" + total;
|
||||
}
|
||||
|
||||
private void UpdateNavigationButtons()
|
||||
{
|
||||
if (_stepManager == null) return;
|
||||
_btnPrevious.interactable = _stepManager.CurrentStepIndex > 0;
|
||||
bool isLast = _stepManager.CurrentStepIndex >= _stepManager.TotalSteps - 1;
|
||||
if (_btnNext != null)
|
||||
if (_btnPrevious) _btnPrevious.interactable = _stepManager.CurrentStepIndex > 0;
|
||||
if (_btnNext)
|
||||
{
|
||||
var label = _btnNext.GetComponentInChildren<TMP_Text>();
|
||||
var label = _btnNext.GetComponentInChildren<Text>();
|
||||
bool isLast = _stepManager.CurrentStepIndex >= _stepManager.TotalSteps - 1;
|
||||
if (label != null) label.text = isLast ? "完成" : "下一步";
|
||||
}
|
||||
}
|
||||
@@ -171,13 +174,9 @@ public class UIManager : MonoBehaviour
|
||||
var gm = GameManager.Instance;
|
||||
if (gm == null) return;
|
||||
if (gm.CurrentMode == ExperimentMode.Exam)
|
||||
{
|
||||
_scoreDisplay?.ShowExamScore();
|
||||
}
|
||||
else
|
||||
{
|
||||
_scoreDisplay?.ShowNotesOnly();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -196,17 +195,18 @@ public class UIManager : MonoBehaviour
|
||||
|
||||
private void OnNextClicked()
|
||||
{
|
||||
if (_stepManager.Mode == ExperimentMode.Exam)
|
||||
if (_stepManager != null && _stepManager.Mode == ExperimentMode.Exam)
|
||||
{
|
||||
var step = _stepManager.GetCurrentStep();
|
||||
if (step != null && step.CompleteType != StepCompleteType.MultipleChoice)
|
||||
_stepManager.OnStepInteractionComplete(1f);
|
||||
}
|
||||
_stepManager.NextStep();
|
||||
_stepManager?.NextStep();
|
||||
}
|
||||
|
||||
private void OnSwitchModeClicked()
|
||||
{
|
||||
if (_stepManager == null) return;
|
||||
var newMode = _stepManager.Mode == ExperimentMode.Learn
|
||||
? ExperimentMode.Exam : ExperimentMode.Learn;
|
||||
_stepManager.SwitchMode(newMode);
|
||||
@@ -214,7 +214,7 @@ public class UIManager : MonoBehaviour
|
||||
|
||||
private void OnReturnClicked()
|
||||
{
|
||||
UnityEngine.SceneManagement.SceneManager.LoadScene("MainMenu");
|
||||
UnityEngine.SceneManagement.SceneManager.LoadScene("main");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user