// open file stream (file must be listed in manifest) private void OpenBundle(UBundle bundle) { var filename = bundle.name; if (LoadBundleFile(bundle, _localPathRoot)) { return; } // 无法打开现有文件, 下载新文件 bundle.AddRef(); AddDownloadTask(DownloadTask.Create( bundle.name, bundle.checksum, bundle.size, bundle.priority, _urls, _localPathRoot, -1, 10, self => { _tasks.Remove(self); _runningTasks--; Schedule(); if (!LoadBundleFile(bundle, _localPathRoot)) { bundle.Load(null); } bundle.RemoveRef(); })); }
private void DownloadBundleFile(UBundle bundle) { // 无法打开现有文件, 下载新文件 bundle.AddRef(); AddDownloadTask(DownloadTask.Create(bundle.bundleInfo, _urls, _localPathRoot, -1, 10, self => { RemoveDownloadTask(self); if (!LoadBundleFile(bundle, _localPathRoot)) { bundle.Load(null); } bundle.RemoveRef(); }), true); }
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(); } }); }); }