IEnumerator _CopyManifestFromStreamingAssets(Action callback) { DirectoryInfo dir = new DirectoryInfo(BundleUtil.GetReadOnlyDirectory() + "/"); Uri baseUri = new Uri(dir.FullName); IDownloader downloader = new WWWDownloader(baseUri, false); // 下载 Manifest IProgressResult <Progress, BundleManifest> manifestResult = downloader.DownloadManifest(BundleSetting.ManifestFilename); yield return(manifestResult.WaitForDone()); if (manifestResult.Exception != null) { LogManager.Log("Downloads BundleManifest failure.Error:{0}", manifestResult.Exception); yield break; } IResources _resources = CreateResources(); context.GetContainer().Register <IResources>(_resources); if (callback != null) { callback.Invoke(); } }
public void DataValid() { // 随机产生bytes数组 // 写入文件作为测试数据 byte[] bytes = RandomData.Build(2048, 512); // 写入文件 const string targetPath = "WWWDownloader.Dat"; bool writed = RandomData.WriteToFile(bytes, TestData.testResource_path + targetPath); Assert.IsTrue(writed); WWWDownloader fd = downloader as WWWDownloader; Assert.IsNotNull(fd); bool runned = false; IEnumerator enumerator = fd.ResourceTask(targetPath + "?" + System.Environment.TickCount.ToString(), (results, error) => { Assert.IsNotNull(results); Assert.AreEqual(bytes.Length, results.Length); Assert.IsTrue(string.IsNullOrEmpty(error)); for (int i = 0; i < bytes.Length; i++) { Assert.AreEqual(bytes [i], results [i]); } // 删除文件 System.IO.File.Delete(TestData.testResource_path + targetPath); runned = true; }); bool completed = enumerator.RunCoroutineWithoutYields(int.MaxValue); Assert.IsTrue(completed); Assert.IsTrue(runned); }
public void ReadError() { WWWDownloader fd = downloader as WWWDownloader; Assert.IsNotNull(fd); bool runned = false; IEnumerator enumerator = fd.ResourceTask("NotExistFile.Dat", (bytes, error) => { Assert.IsNull(bytes); Assert.IsFalse(string.IsNullOrEmpty(error)); runned = true; }); bool completed = enumerator.RunCoroutineWithoutYields(int.MaxValue); Assert.IsTrue(completed); Assert.IsTrue(runned); }
/// <summary> /// 初期化処理 /// baseURLに http://drive.google.com が指定された場合、サーバにGoogleDriveを使用する。 /// </summary> public static void Init(string baseURL, string localCachePath, string fileDictFileID = null) { if (instance == null) { instance = new DownloadManager(); } instance.downloader = WWWDownloader.Create(URLBuilder, localCachePath); instance.downloadQueue = new Queue <WWWDownloader.Params>(); instance.useGoogleDrive = (baseURL == "http://drive.google.com"); if (instance.useGoogleDrive) { instance.baseURL = baseURL + "/uc?export=view&id="; } else { instance.baseURL = baseURL; } CoroutineAgent.Execute(instance.SetFilePathDictionary(fileDictFileID)) .Next(instance.Process()); }