Unity - A计划(永久有效期) 扫二维码继续学习 二维码时效为半小时

(207评价)
优惠后 ¥1899.00优惠前 ¥2499.00 双十一全年最大力度限时优惠
1对1 答疑即时回复7天无理由退款30天价保提问必答

服务保障

1对1 答疑

提供专属的一对一在线答疑,快速答疑解惑。

即时回复

及时响应学习咨询,帮助解决问题。

7天无理由退款

购买后7天内可申请无理由退款。

30天价保

购买后30天内如遇降价,可申请价保。

提问必答

对于提问做到有问必答,帮您扫清学习过程中的种种障碍

Unity发布安卓平台读取XML问题
丑之也发起了问答2018-05-08
1
回复
834
浏览

 

public static XmlNode LoadXmlFile(string xmlPath)//加载XML步骤文件
    {
        XmlDocument xml = new XmlDocument();     
        if (Application.platform == RuntimePlatform.Android)
        {
            localPath = Application.streamingAssetsPath + "/" + xmlPath + ".xml";
            Debug.Log(localPath);
           
           
        }
        else
        {
            //TextAsset textAsset = (TextAsset)Resources.Load(xmlPath, typeof(TextAsset));
            //using (MemoryStream stream = new MemoryStream(textAsset.bytes))
            //{
            //    xml.Load(stream);
            //}     
            localPath = "file://" + UnityEngine.Application.streamingAssetsPath + "/" + xmlPath + ".xml";
            Debug.Log("woshiwebgl");

        }
        WWW www = new WWW(localPath);
        while (!www.isDone)
        {

        }
        xml.LoadXml(www.text); 
        string[] currentPath = xmlPath.Split('/');
        string[] singleNode = currentPath[currentPath.Length - 1].Split('.');
        Debug.Log(singleNode[0]);
        XmlNode xmlNode = xml.SelectSingleNode(singleNode[0]);
        return xmlNode;
    }

在网上找到教程。可以在编辑器运行成功,发布安卓后则读取不到。老师能给一下可以读取成功的代码或者是测试可行的教程链接吗?万分感谢

所有回复
  • siki • 2018-05-08

    如果在安卓上的话,路径前缀是不一样的

    https://blog.csdn.net/u010377179/article/details/52922727

    还有-5条回复,点击查看
    你还没有登录,请先登录或注册!
发表回复
你还没有登录,请先 登录或 注册!