cocos-engine icon indicating copy to clipboard operation
cocos-engine copied to clipboard

命令行构建项目execute-scene-script功能失效

Open tuyazuo opened this issue 6 months ago • 1 comments

Cocos Creator version

3.8.x

System information

Windows10

Issue description

自己写的插件,在onBeforeBuild中,使用 Editor.Message.request('scene', 'execute-scene-script', scene_method('bind')) 调用场景脚本去处理一些资源,在正常模式下是ok的,但在使用命令行构建项目调用时失效。

export const onBeforeBuild: BuildHook.onBeforeBuild = async function(options: ITaskOptions, result: IBuildResult) {
    console.warn('-------------onBeforeBuild----before')
    //等待5s后返回
    const ret = await Editor.Message.request('scene', 'execute-scene-script', scene_method('bind'))
    console.warn(ret)  //!!!命令行构建时,不会等待,直接返回null
    console.warn('-------------onBeforeBuild----after')
};

这里是个简单的插件,可直接用于测试 附件:build-plugin-template.zip

Relevant error log output

命令行构建的日志显示,没有等待,直接返回null了 2025-5-29 23:17:49 - warn: -------------onBeforeBuild----before 2025-5-29 23:17:49 - warn: null 2025-5-29 23:17:49 - warn: -------------onBeforeBuild----after

Steps to reproduce

Minimal reproduction project

No response

tuyazuo avatar May 29 '25 15:05 tuyazuo

补充下: 3.8.3用命令行构建时,写在插件里的console日志可以正常输出在控制台, 3.8.6命令行构建时,插件里的console日志无法输出。 使用win11命令提示符运行构建命令: xxx\CocosCreator.exe --project xxx --build "platform=web-mobile"

tuyazuo avatar May 30 '25 01:05 tuyazuo