Implement limb fixation exam flow

This commit is contained in:
yangbear
2026-07-12 20:34:49 +08:00
parent 1d60eebb4f
commit 79e1fbb70b
71 changed files with 65272 additions and 2574 deletions
+55 -10
View File
@@ -57,40 +57,68 @@ public class PageController : MonoBehaviour
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; }
AutoAssignButtonsByName();
// 绑定首页按钮
if (_btnStart != null) { _btnStart.onClick.AddListener(OnStartClicked); Debug.Log("PageController: _btnStart 绑定成功"); }
if (_btnStart != null) { _btnStart.onClick.RemoveAllListeners(); _btnStart.onClick.AddListener(OnStartClicked); Debug.Log("PageController: _btnStart 绑定成功"); }
else Debug.LogError("PageController: _btnStart 未赋值!");
if (_btnExit != null) { _btnExit.onClick.AddListener(OnExitClicked); Debug.Log("PageController: _btnExit 绑定成功"); }
if (_btnExit != null) { _btnExit.onClick.RemoveAllListeners(); _btnExit.onClick.AddListener(OnExitClicked); Debug.Log("PageController: _btnExit 绑定成功"); }
else Debug.LogError("PageController: _btnExit 未赋值!");
if (_btnBack != null) { _btnBack.onClick.AddListener(OnModeBackClicked); Debug.Log("PageController: _btnBack 绑定成功"); }
if (_btnBack != null) { _btnBack.onClick.RemoveAllListeners(); _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 绑定成功"); }
if (_btnPracticeMode != null) { _btnPracticeMode.onClick.RemoveAllListeners(); _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 绑定成功"); }
if (_btnExamMode != null) { _btnExamMode.onClick.RemoveAllListeners(); _btnExamMode.onClick.AddListener(() => OnModeSelected(ExperimentMode.Exam)); Debug.Log("PageController: _btnExamMode 绑定成功"); }
else Debug.LogError("PageController: _btnExamMode 未赋值!");
if (_btnFixationBack == null && _fixationPanel != null) { var fb = _fixationPanel.transform.Find("BtnBack"); if (fb != null) { _btnFixationBack = fb.GetComponent<Button>(); Debug.Log("PageController: 自动绑定 FixationPanel/BtnBack"); } }
if (_btnFixationBack != null) { _btnFixationBack.onClick.AddListener(OnFixationBackClicked); Debug.Log("PageController: _btnFixationBack 绑定成功"); }
if (_btnFixationBack != null) { _btnFixationBack.onClick.RemoveAllListeners(); _btnFixationBack.onClick.AddListener(OnFixationBackClicked); Debug.Log("PageController: _btnFixationBack 绑定成功"); }
else Debug.LogError("PageController: _btnFixationBack 未找到!");
if (_btnLimbFixation != null) { _btnLimbFixation.onClick.AddListener(() => OnFixationSelected(FixationMethod.LimbFixation)); Debug.Log("PageController: _btnLimbFixation 绑定成功"); }
if (_btnLimbFixation != null) { _btnLimbFixation.onClick.RemoveAllListeners(); _btnLimbFixation.onClick.AddListener(() => OnFixationSelected(FixationMethod.LimbFixation)); Debug.Log("PageController: _btnLimbFixation 绑定成功"); }
else Debug.LogError("PageController: _btnLimbFixation 未赋值!");
if (_btnSplintFixation != null) { _btnSplintFixation.onClick.AddListener(() => OnFixationSelected(FixationMethod.SplintFixation)); Debug.Log("PageController: _btnSplintFixation 绑定成功"); }
if (_btnSplintFixation != null) { _btnSplintFixation.onClick.RemoveAllListeners(); _btnSplintFixation.onClick.AddListener(() => OnFixationSelected(FixationMethod.SplintFixation)); Debug.Log("PageController: _btnSplintFixation 绑定成功"); }
else Debug.LogError("PageController: _btnSplintFixation 未赋值!");
if (_btnExperimentBack == null && _experimentPanel != null) { var eb = _experimentPanel.transform.Find("Navbar/BtnBack"); if (eb != null) { _btnExperimentBack = eb.GetComponent<Button>(); Debug.Log("PageController: 自动绑定 ExperimentPanel/Navbar/BtnBack"); } }
if (_btnExperimentBack != null) { _btnExperimentBack.onClick.AddListener(OnExperimentBackClicked); Debug.Log("PageController: _btnExperimentBack 绑定成功"); }
if (_btnExperimentBack != null) { _btnExperimentBack.onClick.RemoveAllListeners(); _btnExperimentBack.onClick.AddListener(OnExperimentBackClicked); Debug.Log("PageController: _btnExperimentBack 绑定成功"); }
else Debug.LogError("PageController: _btnExperimentBack 未找到!");
ShowPage(Page.Home);
Debug.Log("=== PageController 初始化完成 ===");
}
private void AutoAssignButtonsByName()
{
_btnStart = FindChildButton(_homePagePanel, "BtnStart", _btnStart);
_btnExit = FindChildButton(_homePagePanel, "BtnExit", _btnExit);
_btnBack = FindChildButton(_modeSelectPanel, "BtnBack", _btnBack);
_btnPracticeMode = FindChildButton(_modeSelectPanel, "BtnPracticeMode", _btnPracticeMode);
_btnExamMode = FindChildButton(_modeSelectPanel, "BtnExamMode", _btnExamMode);
_btnFixationBack = FindChildButton(_fixationPanel, "BtnBack", _btnFixationBack);
_btnLimbFixation = FindChildButton(_fixationPanel, "BtnLimbFixation", _btnLimbFixation);
_btnSplintFixation = FindChildButton(_fixationPanel, "BtnSplintFixation", _btnSplintFixation);
}
private Button FindChildButton(GameObject parent, string buttonName, Button fallback)
{
if (parent == null) return fallback;
var buttons = parent.GetComponentsInChildren<Button>(true);
foreach (var button in buttons)
{
if (button != null && button.name == buttonName)
return button;
}
return fallback;
}
private void Update()
{
#if UNITY_EDITOR
@@ -156,6 +184,12 @@ public class PageController : MonoBehaviour
GameManager.Instance.CurrentMode = mode;
GameManager.Instance.CurrentExperimentType = ExperimentType.FractureFixation;
if (mode == ExperimentMode.Learn)
{
var examFlow = FindObjectOfType<ExamFlowManager>();
if (examFlow != null) examFlow.StopExam();
}
ShowPage(Page.Fixation);
}
@@ -184,7 +218,6 @@ public class PageController : MonoBehaviour
{
stepManager.InitializeFromGameManager();
}
StartCoroutine(StartInitialVoiceAndCameraRoutine());
});
}
@@ -199,6 +232,16 @@ public class PageController : MonoBehaviour
}
}
private void StartExamFlowIfNeeded()
{
if (GameManager.Instance == null) return;
if (GameManager.Instance.CurrentMode != ExperimentMode.Exam) return;
if (GameManager.Instance.CurrentFixationMethod != FixationMethod.LimbFixation) return;
var examFlow = FindObjectOfType<ExamFlowManager>();
if (examFlow != null) examFlow.BeginExam();
}
private void OnExperimentBackClicked()
{
ReturnToHome();
@@ -439,6 +482,8 @@ public class PageController : MonoBehaviour
point2.SetActive(true);
Debug.Log("PageController: 镜头切换到camera3point2 已显示");
}
StartExamFlowIfNeeded();
}
private void HideShose()
+11 -1
View File
@@ -145,7 +145,17 @@ public class UIManager : MonoBehaviour
if (_dialogueBubble != null)
{
_dialogueBubble.SetActive(!string.IsNullOrEmpty(text));
bool hasText = !string.IsNullOrEmpty(text);
bool isExam = GameManager.Instance != null && GameManager.Instance.CurrentMode == ExperimentMode.Exam;
bool isExamBubble = _dialogueBubble.transform.Find("step1") != null;
if (!isExam && isExamBubble)
{
_dialogueBubble.SetActive(false);
return;
}
_dialogueBubble.SetActive(hasText);
var txt = _dialogueBubble.GetComponentInChildren<Text>();
if (txt != null) txt.text = text;
}