feat: MCP Unity 场景优化 — 完整交互体系搭建

- 删除重复 Ground
- 创建 [Managers] 空物体,挂载 GameManager + StepManager + ExperimentFlowCoordinator + AudioManager
- Main Camera 挂载 InteractionSystem
- 伤者 InjectedPerson 下创建 5 个交互子物体 (InjuryVisual/Swelling/Pain/VitalSigns/Neuro)
- 创建绑带位置、踝关节、衬垫、夹板位置等空物体
- 道具摆放到位:伤者(2,0.05,5) 施救者(3,0,5) 鞋(2.7,0.15,5.5) 绷带/夹板/急救箱在旁
- InjuryLeg Tag 修正,Ground Tag 修正
- 全部新脚本同步导入 (ExperimentTypes/StepData/ExperimentConfig/StepManager/GameManager/ExperimentFlowCoordinator/InteractionSystem/DraggableObject/HighlightEffect/UIManager/ExamPopup/ScoreDisplay/VideoController/AudioManager/CharacterAnimController/StepAnimationHandler)
- 旧脚本 (ExperimentController/ConfigLoader/AnimationController/HUDController/VideoPlayerController/PopupSystem/ModeSelectionUI) 全部兼容修复或 stub
- 编译通过,0 错误
- Canvas 挂载 UIManager
This commit is contained in:
yangbear
2026-06-24 02:33:48 +08:00
parent 23d3d282f8
commit f0a6b96da5
111 changed files with 11023 additions and 440 deletions
+154
View File
@@ -0,0 +1,154 @@
using UnityEngine;
using UnityEngine.UI;
using TMPro;
using System;
/// <summary>
/// 考核弹窗:选择题 + 操作确认。
/// 挂在弹窗 Panel 上,由 UIManager 调用 Show()。
/// 回调返回 proportion (0~1 得分比例) 和 feedback。
/// </summary>
public class ExamPopup : MonoBehaviour
{
[Header("UI 组件")]
[SerializeField] private GameObject _popupRoot;
[SerializeField] private TMP_Text _questionText;
[SerializeField] private Toggle[] _optionToggles;
[SerializeField] private TMP_Text[] _optionLabels;
[SerializeField] private Button _confirmButton;
[SerializeField] private TMP_Text _feedbackText;
[Header("操作题 UI(点击序列)")]
[SerializeField] private GameObject _operationPanel;
[SerializeField] private TMP_Text _operationHint;
private StepData _currentStep;
private Action<float, string> _onAnswerCallback;
private int _selectedIndex = -1;
private void Awake()
{
_confirmButton?.onClick.AddListener(OnConfirm);
if (_popupRoot != null) _popupRoot.SetActive(false);
}
public void Show(StepData step, Action<float, string> onAnswer)
{
_currentStep = step;
_onAnswerCallback = onAnswer;
_selectedIndex = -1;
if (_feedbackText != null) _feedbackText.text = "";
if (_popupRoot != null) _popupRoot.SetActive(true);
_questionText?.SetText(step.ExamQuestionText);
switch (step.CompleteType)
{
case StepCompleteType.MultipleChoice:
SetupMultipleChoice(step);
break;
case StepCompleteType.ClickObject:
SetupClickObject(step);
break;
case StepCompleteType.SequenceClick:
SetupSequenceClick(step);
break;
default:
SetupDefault(step);
break;
}
}
#region
private void SetupMultipleChoice(StepData step)
{
if (_operationPanel != null) _operationPanel.SetActive(false);
int optionCount = step.ExamOptions?.Length ?? 0;
for (int i = 0; i < _optionToggles.Length; i++)
{
bool active = i < optionCount;
_optionToggles[i].gameObject.SetActive(active);
_optionToggles[i].isOn = false;
_optionToggles[i].onValueChanged.RemoveAllListeners();
int idx = i;
_optionToggles[i].onValueChanged.AddListener((val) => { if (val) _selectedIndex = idx; });
if (active) _optionLabels[i]?.SetText(step.ExamOptions[i]);
}
_confirmButton?.gameObject.SetActive(true);
}
private void SetupClickObject(StepData step)
{
if (_operationPanel != null) _operationPanel.SetActive(true);
if (_optionToggles != null)
foreach (var t in _optionToggles) t.gameObject.SetActive(false);
_confirmButton?.gameObject.SetActive(true);
_operationHint?.SetText($"请点击场景中的 {step.TargetTag} 物体");
}
private void SetupSequenceClick(StepData step)
{
if (_operationPanel != null) _operationPanel.SetActive(true);
if (_optionToggles != null)
foreach (var t in _optionToggles) t.gameObject.SetActive(false);
_confirmButton?.gameObject.SetActive(true);
_operationHint?.SetText("请按正确顺序点击物体,完成后按确定");
}
private void SetupDefault(StepData step)
{
if (_operationPanel != null) _operationPanel.SetActive(false);
if (_optionToggles != null)
foreach (var t in _optionToggles) t.gameObject.SetActive(false);
_confirmButton?.gameObject.SetActive(true);
}
#endregion
#region
private void OnConfirm()
{
if (_currentStep == null) return;
float proportion = 1f;
string feedback = "";
switch (_currentStep.CompleteType)
{
case StepCompleteType.MultipleChoice:
bool correct = _selectedIndex == _currentStep.CorrectOptionIndex;
proportion = correct ? 1f : 0f;
feedback = correct ? "" : _currentStep.ErrorFeedback;
if (!correct && _feedbackText != null)
_feedbackText.text = feedback;
break;
default:
proportion = 1f;
break;
}
if (proportion <= 0f && !string.IsNullOrEmpty(feedback))
{
_onAnswerCallback?.Invoke(0f, feedback);
Hide();
}
else
{
_onAnswerCallback?.Invoke(proportion, feedback);
Hide();
}
}
public void Hide()
{
if (_popupRoot != null) _popupRoot.SetActive(false);
_currentStep = null;
_onAnswerCallback = null;
}
#endregion
}