Esempio n. 1
0
 private DownloadTask AddDownloadTask(DownloadTask newTask)
 {
     for (var node = _tasks.First; node != null; node = node.Next)
     {
         var task = node.Value;
         if (!task.isRunning && !task.isDone)
         {
             if (newTask.priority > task.priority)
             {
                 _tasks.AddAfter(node, newTask);
                 Schedule();
                 return(newTask);
             }
         }
     }
     _tasks.AddLast(newTask);
     Schedule();
     return(newTask);
 }
Esempio n. 2
0
 private void Initialize()
 {
     Utils.Helpers.GetManifest(_urls, _localPathRoot, manifest =>
     {
         new StreamingAssetsLoader(manifest).OpenManifest(streamingAssets =>
         {
             _streamingAssets = streamingAssets;
             var startups     = Utils.Helpers.CollectBundles(manifest, _localPathRoot, bundleInfo =>
             {
                 if (bundleInfo.startup)
                 {
                     return(streamingAssets == null || !streamingAssets.Contains(bundleInfo.name, bundleInfo.checksum, bundleInfo.size));
                 }
                 return(false);
             });
             if (startups.Length > 0)
             {
                 for (int i = 0, size = startups.Length; i < size; i++)
                 {
                     var bundleInfo = startups[i];
                     AddDownloadTask(DownloadTask.Create(bundleInfo, _urls, _localPathRoot, -1, 10, self =>
                     {
                         RemoveDownloadTask(self);
                         if (_tasks.Count == 0)
                         {
                             SetManifest(manifest);
                             ResourceManager.GetListener().OnComplete();
                         }
                     }), false);
                 }
                 ResourceManager.GetListener().OnStartupTask(startups);
                 Schedule();
             }
             else
             {
                 SetManifest(manifest);
                 ResourceManager.GetListener().OnComplete();
             }
         });
     });
 }
Esempio n. 3
0
        public static DownloadTask Create(
            string name, string checksum, int size,
            int priority,
            IList <string> urls,
            string filePathRoot,
            int retry,
            int timeout,
            Action <DownloadTask> callback)
        {
            var task = new DownloadTask();

            task._urls      = urls;
            task._callback  = callback;
            task._name      = name;
            task._checksum  = checksum;
            task._size      = size;
            task._priority  = priority;
            task._retry     = retry;
            task._timeout   = timeout;
            task._finalPath = Path.Combine(filePathRoot, name);
            task.SetUrl();
            return(task);
        }
Esempio n. 4
0
 void OnDestroy()
 {
     ResourceManager.Close();
     DownloadTask.Destroy();
 }
Esempio n. 5
0
 void OnDestroy()
 {
     // Debug.Log("destroy gameobject");
     DownloadTask.Destroy();
 }