Android访问StreamAsset
作者:互联网
卓平台下JAR包变成了压缩包,直接通过File来读取StreamAsset下的文件是不行的
通过UnityWebRequest来读取,以某一个XML文件为例
var path = Path.Combine (Application.streamingAssetsPath, "xxx");// 使用Combine时,路径前不能带有'/',直接以文件夹开头
UnityWebRequest request = UnityWebRequest.Get (path);
request.SendWebRequest ();
while (!request.downloadHandler.isDone) { } // 这里可以用携程,现在是同步加载
while (request.result == UnityWebRequest.Result.InProgress){ } // BUG,当isDown的时候,还有可能在Process,原因未知
if (request.result == UnityWebRequest.Result.Success)
{
TextReader reader = new StringReader (request.downloadHandler.text);
XDocument document = XDocument.Load (reader);
...
}
标签:downloadHandler,request,访问,XDocument,Combine,result,Android,StreamAsset,UnityWeb 来源: https://www.cnblogs.com/Logarius/p/15506138.html