首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如果使用WriteAllBytes,如何使用UnityWebRequest?

如果使用WriteAllBytes,如何使用UnityWebRequest?
EN

Stack Overflow用户
提问于 2021-07-22 04:39:00
回答 1查看 419关注 0票数 0

我使用UnityWebRequest来获取流资产文件夹中的文件,因为WWW已经过时,现在在FileWriteAllBytes上我不能正确使用downloader.bytes,因为它是向我返回一个错误,有人能帮我吗?

代码语言:javascript
复制
        #if UNITY_ANDROID
        // path on streamingasset folder
        string path = System.IO.Path.Combine(Application.streamingAssetsPath, "game.dat");
        UnityWebRequest downloader = UnityWebRequest.Get(path);
        yield return downloader.SendWebRequest();

        while (!downloader.isDone)
        {
            // nothing to be done while downloader gets our db file
        }

        // then save to application.persistentdatapath
        // on this second param i dont know what do right i cant put donwloader.bytes because is obsolete 
        File.WriteAllBytes(dataFilePath, missing); 
        #endif
EN

回答 1

Stack Overflow用户

发布于 2021-07-23 09:12:56

使用DownloadHandler

代码语言:javascript
复制
UnityWebRequest downloader = UnityWebRequest.Get(path);
yield return downloader.SendWebRequest();
DownloadHandler handler = downloader.downloadHandler;
File.WriteAllBytes(dataFilePath, handler.data);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68479267

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档