博客
关于我
关于Unity路径(移动平台动态读取外部文件)
阅读量:215 次
发布时间:2019-02-28

本文共 1412 字,大约阅读时间需要 4 分钟。

?Unity3D????????????????????????????????????????????Windows??Mac??????????PC????????????????????????????????????????????????????????????????????????????????CSV???XML???

?Unity3D???????????????????????????????????????XML?JSON???????????????????????????????????????????????????????????????

???????C#?Unity3D?????XML????????????????????????????XML??????????????

???????

using System;using System.IO;using System.Collections.Generic;using System.Linq;using System.Xml;public class XmlToObject
where T : new(){ public T ParseXml(string filePath) { var xml = File.ReadAllText(filePath); var root = Xml.Deserialize(xml) as XmlNode; if (root.Name != "???") { throw new ArgumentException("?????"); } var obj = new T(); var properties = obj.GetType().GetProperties(); foreach (XmlNode node in root.ChildNodes) { var property = properties.FirstOrDefault(p => p.Name == node.Name); if (property == null) { continue; } var value = node.Value; if (value != null) { property.SetValue(obj, value); } } return obj; }}

?????????????XML?????????????????????????????????????????????????????????????

?????????????????????????????????????????????XML???????????????????????????????????????????????????

转载地址:http://irei.baihongyu.com/

你可能感兴趣的文章
python语音播放
查看>>
python语言:装饰器原理
查看>>
Python 交互式数据可视化详解
查看>>
python语言有哪些优点和缺点_Python有哪些优缺点,你了解吗?
查看>>
Python 从入门到精通:30天速成教程到底有多狠?你能坚持下来吗?
查看>>
Python 从数据库中存储和检索密码的最安全方法
查看>>
Python语言及其应用 - 知识点遍历
查看>>
Python 优化提速的 8 个小技巧
查看>>
Python 余弦相似度与皮尔逊相关系数 计算
查看>>
python 使用execjs 报编码错误解决办法,UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte 0xac in position 145: il
查看>>
python 使用filetype校验文件
查看>>
Python 使用flush函数将缓冲区数据立即写磁盘
查看>>
python 使用in判断不准确,in不好使
查看>>
Python 使用pandas 进行查询和统计详解
查看>>
Redis 配置文件redis.conf详细解释
查看>>
python网络爬虫(2)——scrapy框架的基础使用
查看>>
python网络爬虫实例教程试读_Python网络爬虫实战教程(全套完整版) - 学途无忧网 - 做技术的王者 - Powered By EduSoho...
查看>>
Python 使用哈希函数用于加密
查看>>
Python 依赖管理的革新——Poetry 深度解析
查看>>
python 保留精度及增加去除数字的千位分隔符(金额化数字)
查看>>