kingBook

导航

Cocos Creator Editor 读取一个.plist文件

var fs=require('fs');
var xml2js = require('xml2js');

let strUrl="db://assets/textures/aa.plist";
let plistString=fs.readFileSync(Editor.url(strUrl, 'utf8'),'utf8');
let parseString=xml2js.parseString;
parseString(plistString,function(err,result){
	if(result.plist.dict){
		Editor.log(result.plist.dict[0]);
	}
});

readFileSync()说明:http://nodejs.cn/api/fs.html#fs_fs_readfilesync_path_options
xml2js 文档:https://www.npmjs.com/package/xml2js

posted on 2020-05-21 00:27  kingBook  阅读(755)  评论(0编辑  收藏  举报