This commit is contained in:
2026-06-07 11:49:55 +08:00
parent ff0f3bde54
commit 1897658a00
98 changed files with 9903 additions and 13907 deletions

View File

@@ -138,8 +138,22 @@ namespace BaseGames.Editor
() => IsFieldBound(FindInLoadedScene<BootSequencer>(PersistentName), "_onSplashStartRequest")),
("BootSequencer._onSplashComplete 已绑定",
() => IsFieldBound(FindInLoadedScene<BootSequencer>(PersistentName), "_onSplashComplete")),
("SceneLoader._onLoadingStarted 已绑定",
() => IsFieldBound(FindInLoadedScene<SceneLoader>(PersistentName), "_onLoadingStarted")),
("SceneService._onLoadingStarted 已绑定",
() => IsFieldBound(FindInLoadedScene<SceneService>(PersistentName), "_onLoadingStarted")),
("SceneService._onLoadingComplete 已绑定",
() => IsFieldBound(FindInLoadedScene<SceneService>(PersistentName), "_onLoadingComplete")),
("SceneLoader._onLoadingProgressUpdated 已绑定",
() => IsFieldBound(FindInLoadedScene<SceneLoader>(PersistentName), "_onLoadingProgressUpdated")),
("LoadingScreenManager._loadingRoot 已绑定",
() => IsFieldBound(FindInLoadedScene<LoadingScreenManager>(PersistentName), "_loadingRoot")),
("LoadingScreenManager._progressFill 已绑定",
() => IsFieldBound(FindInLoadedScene<LoadingScreenManager>(PersistentName), "_progressFill")),
("LoadingScreenManager._tipText 已绑定",
() => IsFieldBound(FindInLoadedScene<LoadingScreenManager>(PersistentName), "_tipText")),
("LoadingScreenManager._backgroundArts 非空",
() => IsArrayFieldNonEmpty(FindInLoadedScene<LoadingScreenManager>(PersistentName), "_backgroundArts")),
("LoadingScreenManager._config 已绑定",
() => IsFieldBound(FindInLoadedScene<LoadingScreenManager>(PersistentName), "_config")),
("GameManager._bootSequencer 已绑定",
() => IsFieldBound(FindInLoadedScene<GameManager>(PersistentName), "_bootSequencer")),
("GameManager._onSceneLoadRequest 已绑定",
@@ -168,14 +182,14 @@ namespace BaseGames.Editor
var checks = new (string label, System.Func<bool> fn)[]
{
("MainMenuController 组件存在", () => FindInLoadedScene<MainMenuController>(MainMenuName) != null),
("DataDrivenMainMenuController 组件存在", () => FindInLoadedScene<DataDrivenMainMenuController>(MainMenuName) != null),
("SaveSlotController 组件存在", () => FindInLoadedScene<SaveSlotController>(MainMenuName) != null),
("MainMenuController._onSceneLoadRequest 已绑定",
() => IsFieldBound(FindInLoadedScene<MainMenuController>(MainMenuName), "_onSceneLoadRequest")),
("MainMenuController._onSlotConfirmed 已绑定",
() => IsFieldBound(FindInLoadedScene<MainMenuController>(MainMenuName), "_onSlotConfirmed")),
("MainMenuController._firstGameSceneKey 非空",
() => IsStringFieldNonEmpty(FindInLoadedScene<MainMenuController>(MainMenuName), "_firstGameSceneKey")),
("DataDrivenMainMenuController._onSceneLoadRequest 已绑定",
() => IsFieldBound(FindInLoadedScene<DataDrivenMainMenuController>(MainMenuName), "_onSceneLoadRequest")),
("DataDrivenMainMenuController._onSlotConfirmed 已绑定",
() => IsFieldBound(FindInLoadedScene<DataDrivenMainMenuController>(MainMenuName), "_onSlotConfirmed")),
("DataDrivenMainMenuController._firstGameSceneKey 非空",
() => IsStringFieldNonEmpty(FindInLoadedScene<DataDrivenMainMenuController>(MainMenuName), "_firstGameSceneKey")),
("Scene_MainMenu 已加入 Build Settings",
() => IsInBuildSettings(MainMenuName)),
};
@@ -296,14 +310,23 @@ namespace BaseGames.Editor
CheckField<GameManager>(PersistentName, "_bootSequencer", report, ref passCount, ref failCount);
CheckField<GameManager>(PersistentName, "_onSceneLoadRequest", report, ref passCount, ref failCount);
CheckField<GameManager>(PersistentName, "_onSceneLoaded", report, ref passCount, ref failCount);
CheckField<SceneLoader>(PersistentName, "_onLoadingStarted", report, ref passCount, ref failCount);
CheckField<SceneLoader>(PersistentName, "_onLoadingComplete", report, ref passCount, ref failCount);
CheckField<SceneService>(PersistentName, "_onLoadingStarted", report, ref passCount, ref failCount);
CheckField<SceneService>(PersistentName, "_onLoadingComplete", report, ref passCount, ref failCount);
CheckField<SceneLoader>(PersistentName, "_onLoadingProgressUpdated", report, ref passCount, ref failCount);
// LoadingScreenManager 自身 UI 字段
CheckField<LoadingScreenManager>(PersistentName, "_loadingRoot", report, ref passCount, ref failCount);
CheckField<LoadingScreenManager>(PersistentName, "_progressFill", report, ref passCount, ref failCount);
CheckField<LoadingScreenManager>(PersistentName, "_tipText", report, ref passCount, ref failCount);
if (IsArrayFieldNonEmpty(FindInLoadedScene<LoadingScreenManager>(PersistentName), "_backgroundArts"))
passCount++;
else { failCount++; report.Add("[未绑定] LoadingScreenManager._backgroundArts 为空(在 Persistent。"); }
CheckField<LoadingScreenManager>(PersistentName, "_config", report, ref passCount, ref failCount);
// Main menu scene
CheckComponent<MainMenuController>(MainMenuName, "MainMenuController", report, ref passCount, ref failCount);
CheckField<MainMenuController>(MainMenuName, "_onSceneLoadRequest", report, ref passCount, ref failCount);
CheckField<MainMenuController>(MainMenuName, "_firstGameSceneKey", report, ref passCount, ref failCount, requireNonEmpty: true);
CheckComponent<DataDrivenMainMenuController>(MainMenuName, "DataDrivenMainMenuController", report, ref passCount, ref failCount);
CheckField<DataDrivenMainMenuController>(MainMenuName, "_onSceneLoadRequest", report, ref passCount, ref failCount);
CheckField<DataDrivenMainMenuController>(MainMenuName, "_firstGameSceneKey", report, ref passCount, ref failCount, requireNonEmpty: true);
if (!IsInBuildSettings(MainMenuName))
{
@@ -499,6 +522,19 @@ namespace BaseGames.Editor
return prop != null && !string.IsNullOrEmpty(prop.stringValue);
}
/// <summary>数组字段是否存在且至少有一个非空(对象引用)元素。</summary>
private static bool IsArrayFieldNonEmpty(Object target, string fieldName)
{
if (target == null) return false;
var so = new SerializedObject(target);
var prop = so.FindProperty(fieldName);
if (prop == null || !prop.isArray) return false;
for (int i = 0; i < prop.arraySize; i++)
if (prop.GetArrayElementAtIndex(i).objectReferenceValue != null)
return true;
return false;
}
private static bool IsInBuildSettings(string sceneName)
{
foreach (var scene in EditorBuildSettings.scenes)