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