mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
save settings to pac (#14917)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const texture = require('./texture');
|
||||
const { readFileSync, writeFileSync } = require('fs');
|
||||
|
||||
exports.template = texture.template;
|
||||
|
||||
@@ -10,7 +11,27 @@ exports.$ = texture.$;
|
||||
|
||||
const Elements = texture.Elements;
|
||||
|
||||
exports.methods = texture.methods;
|
||||
exports.methods = Object.assign({}, texture.methods, {
|
||||
// before save meta
|
||||
apply() {
|
||||
const file = this.asset.file;
|
||||
if (file) {
|
||||
try {
|
||||
const pacData = JSON.parse(readFileSync(file, 'utf8'));
|
||||
Object.assign(pacData, {
|
||||
ver: this.meta.ver,
|
||||
importer: this.meta.importer,
|
||||
userData: this.meta.userData,
|
||||
});
|
||||
writeFileSync(file, JSON.stringify(pacData, null, 2), 'utf8');
|
||||
} catch (error) {
|
||||
console.error('Failed to save auto atlas settings!');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
exports.ready = texture.ready;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user