2025-11-27 20:42:46 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 插件安装器
|
|
|
|
|
|
* Plugin Installer
|
2025-12-01 22:28:51 +08:00
|
|
|
|
*
|
|
|
|
|
|
* 现在所有插件都使用统一的 IPlugin 接口,无需适配器。
|
|
|
|
|
|
* Now all plugins use the unified IPlugin interface, no adapter needed.
|
2025-11-27 20:42:46 +08:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
import type { PluginManager } from '@esengine/editor-core';
|
|
|
|
|
|
|
|
|
|
|
|
// 内置插件
|
|
|
|
|
|
import { GizmoPlugin } from '../../plugins/builtin/GizmoPlugin';
|
|
|
|
|
|
import { SceneInspectorPlugin } from '../../plugins/builtin/SceneInspectorPlugin';
|
|
|
|
|
|
import { ProfilerPlugin } from '../../plugins/builtin/ProfilerPlugin';
|
|
|
|
|
|
import { EditorAppearancePlugin } from '../../plugins/builtin/EditorAppearancePlugin';
|
|
|
|
|
|
import { ProjectSettingsPlugin } from '../../plugins/builtin/ProjectSettingsPlugin';
|
2025-12-03 16:19:50 +08:00
|
|
|
|
// Note: PluginConfigPlugin removed - module management is now unified in ProjectSettingsPlugin
|
2025-11-27 20:42:46 +08:00
|
|
|
|
|
2025-12-01 22:28:51 +08:00
|
|
|
|
// 统一模块插件(从编辑器包导入完整插件,包含 runtime + editor)
|
|
|
|
|
|
import { BehaviorTreePlugin } from '@esengine/behavior-tree-editor';
|
|
|
|
|
|
import { Physics2DPlugin } from '@esengine/physics-rapier2d-editor';
|
|
|
|
|
|
import { TilemapPlugin } from '@esengine/tilemap-editor';
|
|
|
|
|
|
import { UIPlugin } from '@esengine/ui-editor';
|
|
|
|
|
|
import { BlueprintPlugin } from '@esengine/blueprint-editor';
|
2025-12-03 16:19:50 +08:00
|
|
|
|
import { MaterialPlugin } from '@esengine/material-editor';
|
|
|
|
|
|
import { SpritePlugin } from '@esengine/sprite-editor';
|
|
|
|
|
|
import { ShaderEditorPlugin } from '@esengine/shader-editor';
|
2025-11-18 14:46:51 +08:00
|
|
|
|
|
|
|
|
|
|
export class PluginInstaller {
|
2025-11-27 20:42:46 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 安装所有内置插件
|
|
|
|
|
|
*/
|
|
|
|
|
|
async installBuiltinPlugins(pluginManager: PluginManager): Promise<void> {
|
|
|
|
|
|
// 内置编辑器插件
|
|
|
|
|
|
const builtinPlugins = [
|
|
|
|
|
|
{ name: 'GizmoPlugin', plugin: GizmoPlugin },
|
|
|
|
|
|
{ name: 'SceneInspectorPlugin', plugin: SceneInspectorPlugin },
|
|
|
|
|
|
{ name: 'ProfilerPlugin', plugin: ProfilerPlugin },
|
|
|
|
|
|
{ name: 'EditorAppearancePlugin', plugin: EditorAppearancePlugin },
|
|
|
|
|
|
{ name: 'ProjectSettingsPlugin', plugin: ProjectSettingsPlugin },
|
2025-11-18 14:46:51 +08:00
|
|
|
|
];
|
|
|
|
|
|
|
2025-11-27 20:42:46 +08:00
|
|
|
|
for (const { name, plugin } of builtinPlugins) {
|
2025-12-03 16:19:50 +08:00
|
|
|
|
if (!plugin || !plugin.manifest) {
|
|
|
|
|
|
console.error(`[PluginInstaller] ${name} is invalid: missing manifest`, plugin);
|
2025-11-27 20:42:46 +08:00
|
|
|
|
continue;
|
|
|
|
|
|
}
|
2025-11-18 14:46:51 +08:00
|
|
|
|
try {
|
2025-11-27 20:42:46 +08:00
|
|
|
|
pluginManager.register(plugin);
|
2025-11-18 14:46:51 +08:00
|
|
|
|
} catch (error) {
|
2025-11-27 20:42:46 +08:00
|
|
|
|
console.error(`[PluginInstaller] Failed to register ${name}:`, error);
|
2025-11-18 14:46:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-11-27 20:42:46 +08:00
|
|
|
|
|
|
|
|
|
|
// 统一模块插件(runtime + editor)
|
|
|
|
|
|
const modulePlugins = [
|
2025-12-03 16:19:50 +08:00
|
|
|
|
{ name: 'SpritePlugin', plugin: SpritePlugin },
|
2025-11-27 20:42:46 +08:00
|
|
|
|
{ name: 'TilemapPlugin', plugin: TilemapPlugin },
|
|
|
|
|
|
{ name: 'UIPlugin', plugin: UIPlugin },
|
|
|
|
|
|
{ name: 'BehaviorTreePlugin', plugin: BehaviorTreePlugin },
|
2025-11-28 10:32:28 +08:00
|
|
|
|
{ name: 'Physics2DPlugin', plugin: Physics2DPlugin },
|
2025-11-29 23:00:48 +08:00
|
|
|
|
{ name: 'BlueprintPlugin', plugin: BlueprintPlugin },
|
2025-12-03 16:19:50 +08:00
|
|
|
|
{ name: 'MaterialPlugin', plugin: MaterialPlugin },
|
|
|
|
|
|
{ name: 'ShaderEditorPlugin', plugin: ShaderEditorPlugin },
|
2025-11-27 20:42:46 +08:00
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
for (const { name, plugin } of modulePlugins) {
|
2025-12-03 16:19:50 +08:00
|
|
|
|
if (!plugin || !plugin.manifest) {
|
|
|
|
|
|
console.error(`[PluginInstaller] ${name} is invalid: missing manifest`, plugin);
|
2025-11-27 20:42:46 +08:00
|
|
|
|
continue;
|
|
|
|
|
|
}
|
2025-12-01 22:28:51 +08:00
|
|
|
|
// 详细日志,检查 editorModule 是否存在
|
2025-12-03 16:19:50 +08:00
|
|
|
|
console.log(`[PluginInstaller] ${name}: manifest.id=${plugin.manifest.id}, hasRuntimeModule=${!!plugin.runtimeModule}, hasEditorModule=${!!plugin.editorModule}`);
|
2025-11-27 20:42:46 +08:00
|
|
|
|
try {
|
|
|
|
|
|
pluginManager.register(plugin);
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error(`[PluginInstaller] Failed to register ${name}:`, error);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-11-18 14:46:51 +08:00
|
|
|
|
}
|
2025-11-27 20:42:46 +08:00
|
|
|
|
}
|