public UFileListBundleAsset(UFileListBundle bundle, string assetPath) : base(assetPath, null) { _bundle = bundle; _bundle.AddRef(); _bundle.completed += OnBundleLoaded; }
//TODO: hints private UBundle GetBundle(Manifest.BundleInfo bundleInfo, EAssetHints hints) { if (_closed) { return(null); } UBundle bundle = null; if (bundleInfo != null) { var bundleName = bundleInfo.name; if (!_bundles.TryGetValue(bundleName, out bundle)) { switch (bundleInfo.type) { case Manifest.BundleType.AssetBundle: bundle = new UAssetBundleBundle(this, bundleInfo, hints); break; case Manifest.BundleType.ZipArchive: bundle = new UZipArchiveBundle(this, bundleInfo); break; case Manifest.BundleType.FileList: bundle = new UFileListBundle(this, bundleInfo); break; } if (bundle != null) { _bundles.Add(bundleName, bundle); _AddDependencies(bundle, hints, bundle.bundleInfo.dependencies); // 第一次访问 UBundle 时进入此处逻辑, 但这之前可能已经使用 EnsureBundles 等方式发起文件下载 // 优先检查是否已经存在下载中的任务, 如果已经存在下载任务, 任务完成时将自动调用 UBundle.Load(stream) var bundleJob = _FindDownloadJob(bundle.name); if (bundleJob == null) { if (!LoadBundleFile(bundle)) { DownloadBundleFile(bundle.bundleInfo, null); } } } } } return(bundle); }