public void Refresh(string key, AssetBundleInfo value) { AssetBundleInfo newABI = new AssetBundleInfo(); newABI.AssetBundleName = value.AssetBundleName; newABI.DependenciesBundleNames = value.DependenciesBundleNames; newABI.HashString = value.HashString; newABI.Md5 = value.Md5; newABI.Crc = value.Crc; newABI.State = value.State; if (AssetBundles.ContainsKey(key)) { AssetBundles[key] = newABI; } else { AssetBundles.Add(key, newABI); } }
//path 一定要是bundle的path private AssetBundle LoadBundle(string path, ref List <string> bundles, int stackSizeForCheck = 0) { if (stackSizeForCheck > MAX_DEPENDENCY_DEEP) { DebugUtil.LogError($"{GetType()}.LoadBundle, path = {path}, dependency stack reach max count({MAX_DEPENDENCY_DEEP}, check if its a bad bundle strategy or a dead code cycle!)"); return(null); } string abKey = path; AssetBundle targetAb; targetAb = AssetBundleCache.GetAssetBundle(abKey); AssetBundleInfo abInfo = VersionManager.Instance.GetAssetBundleInfo(abKey); string[] dependencies = abInfo.DependenciesBundleNames; // 加载自己 if (targetAb == null) { string bundleFilePath = FilePathTools.GetBundleLoadPath(abKey); if (File.Exists(bundleFilePath)) { targetAb = AssetBundle.LoadFromFile(bundleFilePath); } if (targetAb != null) { bundles.Add(abKey); // if (HomeRoomConfigController.Instance != null) // { // var info = HomeRoomConfigController.Instance.GetRoomResInfoByABPath(abKey); // if (info != null) // { // //homeroom 公共库的ab包名字是带versioncode的,需要去掉 // targetAb.name = abKey; // } // } // if (CookingGameConfigController.Instance != null) // { // var info = CookingGameConfigController.Instance.GetRoomResInfoByABPath(abKey); // if (info != null) // { // //cookinggame 公共库的ab包名字是带versioncode的,需要去掉 // targetAb.name = abKey; // } // } // if (ColorResConfigController.Instance != null) // { // var info = ColorResConfigController.Instance.GetRoomResInfoByABPath(abKey); // if (info != null) // { // //colorRes公共库的ab包名字是带versioncode的,需要去掉 // targetAb.name = abKey; // } // } AssetBundleCache.AddAssetBundle(targetAb, abInfo); } else { return(null); } } // 加载依赖包 if (dependencies != null && dependencies.Length > 0) { ++stackSizeForCheck; foreach (string fileName in dependencies) { if (!bundles.Contains(fileName)) { LoadBundle(fileName, ref bundles, stackSizeForCheck); } } } return(targetAb); }
private void OnBundleUnload(AssetBundleInfo abi) { this.state = LoadState.State_None; }