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); }
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(); } }); }); }
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); }
void OnDestroy() { ResourceManager.Close(); DownloadTask.Destroy(); }
void OnDestroy() { // Debug.Log("destroy gameobject"); DownloadTask.Destroy(); }