private bool BundleFileNotExists(BundleDataPublish bundle) { Dictionary<string, string> dictionary = this.CacheBundleMD5Dict; string cachedBundleFilePath = this.GetCachedBundleFilePath(bundle.name); return !File.Exists(cachedBundleFilePath) || !dictionary.ContainsKey(bundle.name) || dictionary[bundle.name] != bundle.MD5; }
public AssetBundle LoadAssetBundle(BundleDataPublish bundle) { AssetBundle assetBundle = this.LoadAssetBundleInternal(bundle); if (this.unusedAssetBundles.Contains(assetBundle)) { this.unusedAssetBundles.Remove(assetBundle); } return assetBundle; }
public bool AssetBundleIsLoaded(BundleDataPublish bundle) { if (this.assetBundles.ContainsKey(bundle)) { AssetBundle x = this.assetBundles[bundle]; return x != null; } return false; }
private void UnloadAsset(BundleDataPublish bundle, bool immediate) { if (bundle.global) { return; } AssetBundle assetBundle = this.assetBundles[bundle]; if (assetBundle != null) { if (immediate) { assetBundle.Unload(true); } else { this.unusedAssetBundles.Add(assetBundle); } } }
private void SaveCacheBundleInfo(BundleDataPublish bundle) { Dictionary<string, string> dictionary = this.CacheBundleMD5Dict; string name = bundle.name; if (dictionary.ContainsKey(name)) { dictionary[name] = bundle.MD5; } else { dictionary.Add(name, bundle.MD5); } this.SaveCacheBundleInfoFile(); }
private AssetBundle LoadAssetBundleInternal(BundleDataPublish bundle) { AssetBundle assetBundle; if (this.assetBundles.ContainsKey(bundle)) { assetBundle = this.assetBundles[bundle]; if (assetBundle != null) { return assetBundle; } this.assetBundles.Remove(bundle); } if (!this.BundleFileNotExists(bundle)) { string cachedBundleFilePath = this.GetCachedBundleFilePath(bundle.name); if (!bundle.encrypt) { assetBundle = AssetBundle.CreateFromFile(cachedBundleFilePath); } else { byte[] binary = BMUtility.AESDecryptAndBZip2DeCompression(cachedBundleFilePath); assetBundle = AssetBundle.CreateFromMemoryImmediate(binary); } } else { byte[] array = Res.LoadDataFromStreamPath(bundle.name); array = this.SaveCacheBundleFile(bundle.name, array); if (bundle.encrypt) { array = BMUtility.AESDecryptAndBZip2DeCompression(array); } assetBundle = AssetBundle.CreateFromMemoryImmediate(array); } this.assetBundles.Add(bundle, assetBundle); return assetBundle; }