Good day, I’m a Korean developer.
I created a plug-in that makes use of construct extensions to erase information when constructing a undertaking after which restore them to their unique state after the construct is full.
My downside is, my plug-in works completely, but when the construct fails, I gained’t return the information I deleted.
Shopping the doc doesn’t present a technique to deal with the construct failure.
What ought to I do?
my cocos creator model is 3.6.1
i can’t discovered onError callback
cocos-build-template.zip (219.4 KB)
I created the plugin straight via right here straight
yeah i do know, however, I clicked this button to create a plug-in, however there’s nonetheless no onError within the BuildHook namespace
Are you able to share a part of the code to see the place issues are tousled?
Hooks.ts
import * as fs from 'fs';
let knowledge: { [path: string]: { contents: string; meta: string } } = {};
async perform take away(path: string): Promise<{ contents: string; meta: string }> {
let full_path = path.substitute('db://', Editor.Venture.path + "https://talk about.cocos2d-x.org/");
let str = fs.readFileSync(full_path, { encoding: 'utf8' });
let str_meta = fs.readFileSync(full_path + '.meta', { encoding: 'utf8' });
console.log(`take away the ${path}`);
await Editor.Message.request('asset-db', 'delete-asset', path);
return { contents: str, meta: str_meta };
}
async perform create(path: string, knowledge: { contents: string; meta: string }) {
console.log(`create the ${path}`);
let full_path = path.substitute('db://', Editor.Venture.path + "https://talk about.cocos2d-x.org/");
await Editor.Message.request('asset-db', 'create-asset', path, knowledge.contents);
fs.writeFileSync(full_path + '.meta', knowledge.meta);
}
export async perform onBeforeBuild(choices) {
knowledge = {};
let pack = choices['packages'] || {};
let module = pack['build-ignore-files'] || {};
let checklist = (module['ignoreList'] || '').cut up(';');
for (let path of checklist) {
let exist_search_path = path.substitute('db://', Editor.Venture.path + "https://talk about.cocos2d-x.org/");
let is_exist = path !== '' && fs.existsSync(exist_search_path);
console.log(path + ' is exist : ' + is_exist.toString());
if (!is_exist) {
proceed;
}
let contents = await take away(path);
knowledge[path] = contents;
}
}
export async perform onAfterBuildAssets(choices) {
for (let path in knowledge) {
await create(path, knowledge[path]);
}
}
export perform load() {
console.log('build-ignore-files load');
}
export perform unload() {
console.log('build-ignore-files unload');
}
that is full hooks code
You possibly can examine if the content material of the template file underneath the engine path is right first