IEnumerator DownloadFileTest(string filePath) { using (var download = BackgroundDownload.Start(new Uri(TEST_URL), filePath)) { yield return(download); Assert.AreEqual(BackgroundDownloadStatus.Done, download.status); Assert.IsTrue(File.Exists(Path.Combine(Application.persistentDataPath, filePath))); } }
void Start() { string fileName = "success.jpb"; string destinationFile = Path.Combine(Application.persistentDataPath, fileName); if (File.Exists(destinationFile)) { Debug.Log("File already downloaded"); return; } var downloads = BackgroundDownload.backgroundDownloads; if (downloads.Length > 0) { StartCoroutine(WaitForDownload(downloads[0])); } else { Uri url = new Uri("https://memegenerator.net/img/images/1154731/success-baby.jpg"); StartCoroutine(WaitForDownload(BackgroundDownload.Start(url, fileName))); } }