fix: WebGL关闭Brotli压缩解决服务器部署.br解析问题; 新增PageController编辑器页面预览下拉框; 创建FractureFixationConfig ScriptableObject; 修复ExperimentFlowCoordinator自动初始化问题

This commit is contained in:
yangbear
2026-06-24 06:05:55 +08:00
parent a6a7fd06d4
commit 3b4438731d
9 changed files with 494 additions and 47 deletions
+59 -10
View File
@@ -36,7 +36,13 @@ public class PageController : MonoBehaviour
[SerializeField] [TextArea(2, 4)] private string _examModeDesc =
"● 考核评估模式:限定时间,完成后系统自动评分,并提供详细反馈报告。";
private enum Page { Home, ModeSelect, Fixation, Experiment }
[Header("=== 编辑器预览(仅 Editor 模式有效)===")]
[SerializeField] private EditorPreviewPage _editorPreview = EditorPreviewPage.None;
// Page 枚举改为 publicInspector 中可通过 _editorPreview 切换
public enum Page { Home, ModeSelect, Fixation, Experiment }
public enum EditorPreviewPage { None, Home, ModeSelect, Fixation, Experiment }
private Page _currentPage = Page.Home;
private ExperimentMode _selectedMode = ExperimentMode.Learn;
@@ -66,6 +72,58 @@ public class PageController : MonoBehaviour
ShowPage(Page.Home);
}
#if UNITY_EDITOR
/// <summary>
/// 在 Inspector 中修改 _editorPreview 下拉框时,立即切换 Scene View 中显示的页面,
/// 方便编辑不同页面的 UI 布局。仅在非运行状态下生效。
/// </summary>
private void OnValidate()
{
if (Application.isPlaying) return;
// 延迟一帧执行,避免在序列化过程中修改场景导致警告
UnityEditor.EditorApplication.delayCall += () =>
{
if (this == null) return;
if (Application.isPlaying) return;
switch (_editorPreview)
{
case EditorPreviewPage.None:
// 不做任何切换,保留当前状态
break;
case EditorPreviewPage.Home:
ShowPageEditMode(Page.Home);
break;
case EditorPreviewPage.ModeSelect:
ShowPageEditMode(Page.ModeSelect);
break;
case EditorPreviewPage.Fixation:
ShowPageEditMode(Page.Fixation);
break;
case EditorPreviewPage.Experiment:
ShowPageEditMode(Page.Experiment);
break;
}
// 切换完成后重置为 None,避免与后续操作冲突
_editorPreview = EditorPreviewPage.None;
};
}
private void ShowPageEditMode(Page page)
{
if (_homePagePanel != null) _homePagePanel.SetActive(page == Page.Home);
if (_modeSelectPanel != null) _modeSelectPanel.SetActive(page == Page.ModeSelect);
if (_fixationPanel != null) _fixationPanel.SetActive(page == Page.Fixation);
if (_uiManager != null)
_uiManager.enabled = (page == Page.Experiment);
Debug.Log($"PageController(编辑器预览): 切换到 [{page}]");
}
#endif
#region
private void ShowPage(Page page)
@@ -76,7 +134,6 @@ public class PageController : MonoBehaviour
if (_modeSelectPanel != null) _modeSelectPanel.SetActive(page == Page.ModeSelect);
if (_fixationPanel != null) _fixationPanel.SetActive(page == Page.Fixation);
// 实验内界面:隐藏所有实验 UI,等模式确定后再由 UIManager 激活
if (_uiManager != null)
_uiManager.enabled = (page == Page.Experiment);
}
@@ -99,18 +156,15 @@ public class PageController : MonoBehaviour
#endif
}
// 模式选择页 -> 返回首页
private void OnModeBackClicked()
{
ShowPage(Page.Home);
}
// 选择模式后 -> 进入固定方式选择页
private void OnModeSelected(ExperimentMode mode)
{
_selectedMode = mode;
// 更新说明文案显示当前选择
if (_modeDescText != null)
{
_modeDescText.text = mode == ExperimentMode.Learn
@@ -121,10 +175,8 @@ public class PageController : MonoBehaviour
ShowPage(Page.Fixation);
}
// 固定方式选择页 -> 返回模式选择页
private void OnFixationBackClicked()
{
// 恢复原始说明文案
if (_modeDescText != null)
{
_modeDescText.text = _practiceModeDesc + "\n\n" + _examModeDesc;
@@ -133,7 +185,6 @@ public class PageController : MonoBehaviour
ShowPage(Page.ModeSelect);
}
// 选择固定方式后 -> 进入实验
private void OnFixationSelected(FixationMethod method)
{
var gm = GameManager.Instance;
@@ -146,10 +197,8 @@ public class PageController : MonoBehaviour
gm.CurrentMode = _selectedMode;
gm.CurrentFixationMethod = method;
// 切换到实验界面
ShowPage(Page.Experiment);
// 启动实验流程
var stepManager = FindObjectOfType<StepManager>();
if (stepManager != null)
{