fix: 修复项目切换时运行时和系统重复初始化问题 (#267)
* feat(editor): 添加 GitHub Discussions 社区论坛功能 * chore: 更新 pnpm-lock.yaml * chore: 删除测试图片 * refactor: 改用 Imgur 图床上传图片 * fix: 修复项目切换时运行时和系统重复初始化问题 * fix: 修复多个编辑器问题 * feat: 添加脚本编辑器配置和类型定义支持 * feat: 实现资产 .meta 文件自动生成功能
This commit is contained in:
67
packages/editor-app/src/plugins/builtin/AssetMetaPlugin.ts
Normal file
67
packages/editor-app/src/plugins/builtin/AssetMetaPlugin.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* Asset Meta Plugin
|
||||
* 资产元数据插件
|
||||
*
|
||||
* Handles .meta file generation for project assets.
|
||||
* 处理项目资产的 .meta 文件生成。
|
||||
*/
|
||||
|
||||
import type { ServiceContainer } from '@esengine/ecs-framework';
|
||||
import { createLogger } from '@esengine/ecs-framework';
|
||||
import type { IPlugin, IEditorModuleLoader, ModuleManifest } from '@esengine/editor-core';
|
||||
import { AssetRegistryService } from '@esengine/editor-core';
|
||||
|
||||
const logger = createLogger('AssetMetaPlugin');
|
||||
|
||||
/**
|
||||
* Asset Meta Editor Module
|
||||
* 资产元数据编辑器模块
|
||||
*/
|
||||
class AssetMetaEditorModule implements IEditorModuleLoader {
|
||||
private _assetRegistry: AssetRegistryService | null = null;
|
||||
|
||||
async install(_services: ServiceContainer): Promise<void> {
|
||||
// 创建 AssetRegistryService 并初始化
|
||||
// Create AssetRegistryService and initialize
|
||||
this._assetRegistry = new AssetRegistryService();
|
||||
|
||||
// 初始化服务(订阅 project:opened 事件)
|
||||
// Initialize service (subscribes to project:opened event)
|
||||
await this._assetRegistry.initialize();
|
||||
|
||||
logger.info('AssetRegistryService initialized');
|
||||
}
|
||||
|
||||
async uninstall(): Promise<void> {
|
||||
if (this._assetRegistry) {
|
||||
this._assetRegistry.unloadProject();
|
||||
this._assetRegistry = null;
|
||||
}
|
||||
logger.info('Uninstalled');
|
||||
}
|
||||
|
||||
async onEditorReady(): Promise<void> {
|
||||
logger.info('Editor is ready');
|
||||
}
|
||||
}
|
||||
|
||||
const manifest: ModuleManifest = {
|
||||
id: '@esengine/asset-meta',
|
||||
name: '@esengine/asset-meta',
|
||||
displayName: 'Asset Meta',
|
||||
version: '1.0.0',
|
||||
description: 'Generates .meta files for project assets | 为项目资产生成 .meta 文件',
|
||||
category: 'Other',
|
||||
icon: 'FileJson',
|
||||
isCore: true,
|
||||
defaultEnabled: true,
|
||||
isEngineModule: false, // 不是引擎模块,不会被打包到 runtime
|
||||
canContainContent: false,
|
||||
dependencies: [],
|
||||
exports: {}
|
||||
};
|
||||
|
||||
export const AssetMetaPlugin: IPlugin = {
|
||||
manifest,
|
||||
editorModule: new AssetMetaEditorModule()
|
||||
};
|
||||
Reference in New Issue
Block a user