no message
This commit is contained in:
@@ -14,6 +14,7 @@ import {
|
||||
} from './core/Define';
|
||||
import { EventManager, EventType } from './core/EventManager';
|
||||
import { ExternalLevelInfo, JsBridge } from './bridge/JsBridge';
|
||||
import { ensureRuntimeAssetsForLevel } from './core/RuntimePack';
|
||||
import {
|
||||
hasLevel, getMaxLevelId, getMinLevelId, LEVEL_ID_BASE, resolveLevelConfig,
|
||||
nextLevelId, prevLevelId,
|
||||
@@ -25,7 +26,7 @@ import {
|
||||
} from './level/EntitySpawnPlacement';
|
||||
import { EntityVisualOptions } from './visual/EntityTextureResolver';
|
||||
import { getLevelPrefabResourcePath } from './level/LevelPrefabPaths';
|
||||
import { loadLevelPrefab } from './level/LevelPrefabLoader';
|
||||
import { loadLevelPrefab as loadLevelPrefabImpl } from './level/LevelPrefabLoader';
|
||||
import { PlayerController } from './controller/PlayerController';
|
||||
import { VehicleController } from './controller/VehicleController';
|
||||
import { PropController } from './controller/PropController';
|
||||
@@ -52,6 +53,13 @@ interface GridEntry {
|
||||
node: Node;
|
||||
}
|
||||
|
||||
/** Web 主站:优先走 loader 注入的 loadLevelPrefab(按关下载 + 内存 bundle) */
|
||||
function loadLevelPrefabForRuntime(path: string) {
|
||||
const hook = (globalThis as { __tfrhLoadLevelPrefab?: typeof loadLevelPrefabImpl }).__tfrhLoadLevelPrefab;
|
||||
if (typeof hook === 'function') return hook(path);
|
||||
return loadLevelPrefabImpl(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* 主站唯一入口组件(原 GameManager + GameController 合并)。
|
||||
* Inspector:填写 inputLevel,预览 ▶ 后点 SwitchLevel(对齐 Unity TestGame2)。
|
||||
@@ -793,6 +801,13 @@ export class GameController extends Component {
|
||||
async createNewLevel(levelID: number) {
|
||||
if (this.creating) return;
|
||||
this.creating = true;
|
||||
try {
|
||||
await ensureRuntimeAssetsForLevel(levelID);
|
||||
} catch (e) {
|
||||
console.error('[GameController] 运行时资源加载失败', e);
|
||||
this.creating = false;
|
||||
return;
|
||||
}
|
||||
const config = resolveLevelConfig(levelID);
|
||||
if (!config || !this.mainLevelEntrance) {
|
||||
this.creating = false;
|
||||
@@ -809,7 +824,7 @@ export class GameController extends Component {
|
||||
|
||||
const path = getLevelPrefabResourcePath(levelID, config);
|
||||
try {
|
||||
const prefab = await loadLevelPrefab(path);
|
||||
const prefab = await loadLevelPrefabForRuntime(path);
|
||||
await VisualAssets.preload(this.uiStyle);
|
||||
// 在 instantiate 前无法拦截;先禁用 prefab 内 GridSnapHelper 的 showGrid
|
||||
GridSnapHelper.stripBeforePlayFromPrefab(prefab);
|
||||
|
||||
Reference in New Issue
Block a user