Exemplo n.º 1
0
 // 当前任务数, 总任务数, 当前任务进度
 public static IEnumerator DownloadBundlesCo(
     string localPathRoot,
     Manifest.BundleInfo[] bundles,
     IList <string> urls,
     StreamingAssetsLoader streamingAssets,
     Action <int, int, ITask> onProgress,
     Action onComplete)
 {
     for (int i = 0, size = bundles.Length; i < size; i++)
     {
         var bundleInfo = bundles[i];
         if (streamingAssets != null && streamingAssets.Contains(bundleInfo.name, bundleInfo.checksum, bundleInfo.size))
         {
             // Debug.LogWarning($"skipping embedded bundle {bundleInfo.name}");
             continue;
         }
         var task     = DownloadTask.Create(bundleInfo, urls, localPathRoot, -1, 10, null).SetDebugMode(true);
         var progress = -1.0f;
         task.Run();
         while (!task.isDone)
         {
             if (progress != task.progress)
             {
                 progress = task.progress;
                 onProgress(i, size, task);
             }
             yield return(null);
         }
     }
     onComplete();
 }
Exemplo n.º 2
0
 public static void DownloadBundles(
     string localPathRoot,
     Manifest.BundleInfo[] bundles,
     IList <string> urls,
     StreamingAssetsLoader streamingAssets,
     Action <int, int, ITask> onProgress,
     Action onComplete)
 {
     JobScheduler.DispatchCoroutine(DownloadBundlesCo(localPathRoot, bundles, urls, streamingAssets, onProgress, onComplete));
 }
Exemplo n.º 3
0
        private void LoadText()
        {
            string csvPath = System.IO.Path.Combine(Application.streamingAssetsPath, "Csv/sample.csv");

            StreamingAssetsLoader.ReadAllBytes(csvPath, bytes =>
            {
                if (bytes == null)
                {
                    Debug.Log($"ファイルが存在しません Path:{csvPath}");
                    return;
                }
                string txt = Encoding.UTF8.GetString(bytes);

                Debug.Log(txt);
            });
        }
Exemplo n.º 4
0
        private void LoadImage()
        {
            string imgPath = System.IO.Path.Combine(Application.streamingAssetsPath, "Image/sample.png");

            StreamingAssetsLoader.ReadAllBytes(imgPath, bytes =>
            {
                if (bytes == null)
                {
                    Debug.Log($"ファイルが存在しません Path:{imgPath}");
                    return;
                }

                Texture2D texture = new Texture2D(1024, 1024);

                texture.LoadImage(bytes);

                image.sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero);
            });
        }
Exemplo n.º 5
0
 public static bool ExistStreamingFile(string path)
 {
     return(StreamingAssetsLoader.Exists(path));
 }