internal static BundleRequest LoadBundle(string assetBundleName, bool asyncMode) { if (string.IsNullOrEmpty(assetBundleName)) { GameLog.LogError("assetBundleName == null"); return(null); } assetBundleName = RemapVariantName(assetBundleName); var url = GetDataPath(assetBundleName) + assetBundleName; BundleRequest bundle; if (_bundles.TryGetValue(url, out bundle)) { bundle.Retain(); _loadingBundles.Add(bundle); return(bundle); } if (url.StartsWith("http://", StringComparison.Ordinal) || url.StartsWith("https://", StringComparison.Ordinal) || url.StartsWith("file://", StringComparison.Ordinal) || url.StartsWith("ftp://", StringComparison.Ordinal)) { bundle = new WebBundleRequest(); } else { bundle = asyncMode ? new BundleRequestAsync() : new BundleRequest(); } bundle.name = url; _bundles.Add(url, bundle); if (MAX_BUNDLES_PERFRAME > 0 && (bundle is BundleRequestAsync || bundle is WebBundleRequest)) { _toloadBundles.Add(bundle); } else { bundle.Load(); _loadingBundles.Add(bundle); GameLog.Log("LoadBundle: " + url); } bundle.Retain(); return(bundle); }
private static BundleRequest Load(string assetBundleName, bool isLoadingAssetBundleManifest, bool asyncMode) { if (string.IsNullOrEmpty(assetBundleName)) { Debug.LogError("assetBundleName == null"); return(null); } if (!isLoadingAssetBundleManifest) { if (manifest == null) { Debug.LogError("Please initialize AssetBundleManifest by calling Bundles.Initialize()"); return(null); } assetBundleName = RemapVariantName(assetBundleName); } var url = GetDataPath(assetBundleName) + assetBundleName; for (int i = 0, max = _bundles.Count; i < max; i++) { var item = _bundles [i]; if (!item.url.Equals(url)) { continue; } item.Retain(); return(item); } BundleRequest bundle; if (url.StartsWith("http://", StringComparison.Ordinal) || url.StartsWith("https://", StringComparison.Ordinal) || url.StartsWith("file://", StringComparison.Ordinal) || url.StartsWith("ftp://", StringComparison.Ordinal)) { bundle = new WebBundleRequest { hash = manifest != null?manifest.GetAssetBundleHash(assetBundleName) : new Hash128(), cache = !isLoadingAssetBundleManifest } } ; else { bundle = asyncMode ? new BundleAsyncRequest() : new BundleRequest(); } bundle.url = url; _bundles.Add(bundle); if (MAX_LOAD_SIZE_PERFREME > 0 && (bundle is BundleAsyncRequest || bundle is WebBundleRequest)) { _ready2Load.Add(bundle); } else { bundle.Load(); } if (!isLoadingAssetBundleManifest) { LoadDependencies(bundle, assetBundleName, asyncMode); } bundle.Retain(); Log("Load->" + url); return(bundle); }