Cocos Creator Editor 读取一个.plist文件

时间:2020-05-21 09:38:26   收藏:0   阅读:190
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

原文:https://www.cnblogs.com/kingBook/p/12927465.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!