【问题标题】:How to use WriteAllBytes if using UnityWebRequest?如果使用 UnityWebRequest,如何使用 WriteAllBytes?
【发布时间】:2021-07-22 04:39:00
【问题描述】:

我使用 UnityWebRequest 获取流资产文件夹上的文件,因为 WWW 已过时,现在在 FileWriteAllBytes 上我无法正确 downloader.bytes 因为它向我返回错误,有人可以帮助我

        #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

【问题讨论】:

    标签: unity3d byte unitywebrequest


    【解决方案1】:

    使用下载处理程序

    UnityWebRequest downloader = UnityWebRequest.Get(path);
    yield return downloader.SendWebRequest();
    DownloadHandler handler = downloader.downloadHandler;
    File.WriteAllBytes(dataFilePath, handler.data);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-06
      • 1970-01-01
      • 2019-01-26
      • 1970-01-01
      • 2021-01-13
      • 2020-11-11
      相关资源
      最近更新 更多