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

你可能感兴趣的文章
NS3 IP首部校验和
查看>>
NSDateFormatter的替代方法
查看>>
NSError 的使用方法
查看>>
nsis 安装脚本示例(转)
查看>>
NSJSON的用法(oc系统自带的解析方法)
查看>>
nslookup 的基本知识与命令详解
查看>>
NSOperation基本操作
查看>>
NSRange 范围
查看>>
NSSet集合 无序的 不能重复的
查看>>
NSURLSession下载和断点续传
查看>>
NSUserdefault读书笔记
查看>>
NT AUTHORITY\NETWORK SERVICE 权限问题
查看>>
NT symbols are incorrect, please fix symbols
查看>>
ntelliJ IDEA 报错:找不到包或者找不到符号
查看>>
ntko web firefox跨浏览器插件_深度比较:2019年6个最好的跨浏览器测试工具
查看>>
ntko文件存取错误_苹果推送 macOS 10.15.4:iCloud 云盘文件夹共享终于来了
查看>>
ntpdate 通过外网同步时间
查看>>
NTPD使用/etc/ntp.conf配置时钟同步详解
查看>>
NTP及Chrony时间同步服务设置
查看>>
NTP配置
查看>>