码迷,mamicode.com
首页 > 编程语言 > 详细

Unity使用Mono.Xml代替System.Xml 测试

时间:2017-03-25 16:26:14      阅读:267      评论:0      收藏:0      [点我收藏+]

标签:mon   使用   wave   source   runner   reader   single   ima   分享   

测试环境


操作系统:Windows8.1

开发工具:Unity5.5.2


1、新建一个测试项目,观测引用System.Xml与Mono.Xml解析文件正确性,与打包后APK体积大小。

2、Mono.Xml 用例

using UnityEngine;
using Mono.Xml;
using System.Security;

public class MonoXmlTest : MonoBehaviour {

    
    void Start () {

        SecurityParser parser = new SecurityParser();

        string xmlPath = "test";

        parser.LoadXml(Resources.Load(xmlPath).ToString());

        SecurityElement element = parser.ToXml();
        
        foreach (SecurityElement node in element.Children)
        {         
            if (node.Tag == "table")
            {
                string wave = node.Attribute("wave");
                string level = node.Attribute("level");
                string name = node.Attribute("name");
                Debug.Log("wave:" + wave + " level:" + level + " name:" + name);
            }

        }
    }
    
}
  1. 结果正确: 技术分享
  2. 安装包大小: 技术分享
  3. 编译日志可以观测到没有引用System.Xml.dll(该文件约1mb)

    Mono dependencies included in the build
    Dependency assembly - Mono.Security.dll
    Dependency assembly - System.Core.dll
    Dependency assembly - System.dll
    Dependency assembly - mscorlib.dll
    Dependency assembly - UnityEngine.UI.dll
    Dependency assembly - UnityEngine.Networking.dll
    Dependency assembly - UnityEngine.PlaymodeTestsRunner.dll
    Dependency assembly - Assembly-CSharp.dll

 


 

3、System.xml用例

using UnityEngine;
using System.Xml;

public class SystemXmlTest : MonoBehaviour {

    // Use this for initialization
    void Start () {
     
            XmlDocument xml = new XmlDocument();
            XmlReaderSettings set = new XmlReaderSettings();            
            xml.LoadXml(Resources.Load("test").ToString());
            
            XmlNodeList nodes = xml.SelectSingleNode("ROOT").ChildNodes;
            
            foreach (XmlElement node in nodes)
            {
                string wave = node.GetAttribute("wave");
                string level = node.GetAttribute("level");
                string name = node.GetAttribute("name");

                Debug.Log("wave:" + wave + " level:" + level + " name:" + name);
        }

    }
    
}
  1. 结果正确:技术分享
  2. 安装包大小:技术分享
  3. 编译日志:可以观测到引用System.Xml.dll(该文件约1mb)  
    编译日志:可以观测到引用System.Xml.dll(该文件约1mb)
    
    Mono dependencies included in the build
    Dependency assembly - Mono.Security.dll
    Dependency assembly - System.Core.dll
    Dependency assembly - System.Xml.dll
    Dependency assembly - System.dll
    Dependency assembly - mscorlib.dll
    Dependency assembly - UnityEngine.UI.dll
    Dependency assembly - UnityEngine.Networking.dll
    Dependency assembly - UnityEngine.PlaymodeTestsRunner.dll
    Dependency assembly - Assembly-CSharp.dll

     


 4、结论:使用Mono.Xml代替System.Xml在APK安装包编译后,体积减小约400kb,建议使用Mono.Xml 

Unity使用Mono.Xml代替System.Xml 测试

标签:mon   使用   wave   source   runner   reader   single   ima   分享   

原文地址:http://www.cnblogs.com/heitao/p/6617398.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!