游戏技术文章

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

时间:2017-3-25 21:13:29  作者:棋牌资源网  来源:棋牌资源网  查看:7886  评论:0
内容摘要:测试环境操作系统:Windows8.1开发工具:Unity5.5.21、新建一个测试项目,观测引用System.Xml与Mono.Xml解析文件正确性,与打包后APK体积大小。2、Mono.Xml 用例using UnityEngine;using Mono.Xml;using ...
测试环境

操作系统: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. 结果正确: Unity使用Mono.Xml代替System.Xml_测试
  2. 安装包大小: Unity使用Mono.Xml代替System.Xml_测试
  3. 编译日志可以观测到没有引用System.Xml.dll(该文件约1mb)

    1
    2
    3
    4
    5
    6
    7
    8
    9
    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. 结果正确:Unity使用Mono.Xml代替System.Xml_测试
  2. 安装包大小:Unity使用Mono.Xml代替System.Xml_测试
  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测试 

欢迎加入VIP,【VIP售价:只要288元永久VIP会员】畅享商业棋牌游戏程序下载,点击开通!

下载说明


☉本站所有源码和资源均由站长亲自测试-绝对保证都可以架设,运营!
☉如源码和资源有损坏或所有链接均不能下载,请告知管理员,

☉本站软件和源码大部分为站长独资,资源购买和收集,放心下载!

☉唯一站长QQ:1004003180  [人格担保-本站注重诚信!]

☉购买建议E-mail:1004003180@qq.com   源码收购 E-mail:1004003180@qq.com    

☉本站文件解压密码  【文章内都自带解压密码,每个密码不同!】


本站提供的所有源码,均来源站长提供,仅学习交流 浙ICP备09009969号

由此产生不良后果和法律责任与本站无关,如果侵犯了您的版权,请来信告知 1004003180@qq.com 将及时更正和删除! 

Copyright © 2008-2022 棋牌资源网,你身边的棋牌资源下载站    All Rights Reserved