您的位置:首页 > 移动开发 > Unity3D

Unity Android及PC 外部Xml读取

2014-04-25 20:00 489 查看
using UnityEngine;

using System.Collections;

using System.Xml;

public class Test : MonoBehaviour {

    public UILabel label;

    private WWW www;

    void Start()

    {

        string url = Application.streamingAssetsPath + "/tip.xml";

        label.text = url;

        if (Application.platform == RuntimePlatform.Android)

        {

            www = new WWW(url);

        }

        else

        {

            XmlDocument xmldoc = new XmlDocument();

            xmldoc.Load(url);

            label.text = xmldoc.OuterXml;

        }

    }

    void Update()

    {

        if (www!=null&&www.isDone)

        {

            label.text = www.text;

        }

    }

}

MI 2SC 运行效果 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: