kingBook

导航

Cocos Creator Editor 读取和保存.meta

var fs=require('fs');

//读取.meta
//result.path 如:E:\projects\ccc_test\assets\arrow.plist
let plistMetaPath=result.path+".meta"
let plistMetaStrings=fs.readFileSync(plistMetaPath,'utf8');
let plistMetaData=JSON.parse(plistMetaStrings);
//Editor.log(plistMetaData);
//Editor.log(plistMetaData.rawTextureUuid);
//Editor.log(plistMetaData.subMetas);

//保存.meta
let plistMetaDataStrings=JSON.stringify(plistMetaData,null,"\t");
Editor.assetdb.saveMeta(plistMetaData.uuid,plistMetaDataStrings,(err,meta)=>{});
//也可以使用fs.writeFileSync方法保存.meta
//const data=new Uint8Array(Buffer.from(plistMetaDataStrings));
//fs.writeFileSync(plistMetaPath,data,'utf8');

//保存后刷新资源
Editor.assetdb.refresh(result.path,(err,results)=>{});

posted on 2020-07-23 00:36  kingBook  阅读(668)  评论(0编辑  收藏  举报