/// <summary> /// 卸载 /// </summary> /// <param name="assetName">根据加载路径卸载</param> /// <param name="isForceUnload">强制卸载</param> public void UnloadAsset(string assetName, bool isForceUnload = false) { //非hash模式,需要debugRuntime // if (!this.AssetConfigLoder.IsHashName) // { // assetName = ZString.Format(DEBUG_RUNTIME, assetName); // } var(assetBundleItem, dependAssetList) = AssetConfigLoder.GetDependAssets(assetName); //添加主资源一起卸载 dependAssetList.Add(assetBundleItem); //卸载 for (int i = 0; i < dependAssetList.Count; i++) { var assetPath = dependAssetList[i].AssetBundlePath; AssetBundleWapper abw = null; if (AssetbundleMap.TryGetValue(assetPath, out abw)) { if (isForceUnload) { abw.UnLoad(); } else { abw.Unuse(); } } } }
/// <summary> /// 卸载 /// </summary> /// <param name="path">根据加载路径卸载</param> /// <param name="isForceUnload">强制卸载</param> public void UnloadAsset(string path, bool isForceUnload = false) { if (!this.loder.Manifest.IsHashName) { path = ZString.Format(RUNTIME, path); } var assetList = loder.Manifest.GetDependenciesByName(path); if (assetList == null) { return; } //卸载 for (int i = 0; i <= assetList.Count; i++) { var assetPath = assetList[i]; AssetBundleWapper abw = null; if (AssetbundleMap.TryGetValue(assetPath, out abw)) { if (isForceUnload) { abw.UnLoad(); } else { abw.Unuse(); } } } }