博客
关于我
关于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/

你可能感兴趣的文章
POJ 1321 棋盘问题
查看>>
poj 1321(回溯)
查看>>
Qt高级——Qt元对象系统源码解析
查看>>
qt调用vs2008编写的dll动态库(隐式调用)
查看>>
Qt读取注册表默认值
查看>>
poj 1679 判断MST是不是唯一的 (次小生成树)
查看>>
POJ 1703 Find them, Catch them
查看>>
POJ 1703 Find them, Catch them 并查集
查看>>
POJ 1738 An old Stone Game(石子合并)
查看>>
POJ 1740 A New Stone Game(博弈)题解
查看>>
Qt网络编程之实例二POST方式
查看>>
POJ 1765 November Rain
查看>>
poj 1860 Currency Exchange
查看>>
POJ 1961 Period
查看>>
POJ 2019 Cornfields (二维RMQ)
查看>>
poj 2057 The Lost House 贪心思想在动态规划上的应用
查看>>
poj 2057 树形DP,数学期望
查看>>
poj 2112 最优挤奶方案
查看>>
Qt编写自定义控件12-进度仪表盘
查看>>
SpringBoot主启动原理在SpringApplication类《第六课》
查看>>