0

I use UnityWebRequest in getting the file on streamingassets folder because WWW is obsolete, now on FileWriteAllBytes i cant right downloader.bytes because it is return an error to me can someone help me

        #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

1 Answers1

0

use DownloadHandler

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