public void UnLoadAssetBundle(string bundlePath) { FixedBundleFilePath(ref bundlePath); BundleCounter bc = null; if (bundleDicts.TryGetValue(bundlePath, out bc)) { bc.count--; if (bc.count <= 0) { bc.asset.Unload(false); bundleDicts.Remove(bundlePath); } } }
public AssetBundle LoadAssetBundle(string bundlePath) { FixedBundleFilePath(ref bundlePath); BundleCounter bc = null; if (bundleDicts.TryGetValue(bundlePath, out bc)) { bc = bundleDicts [bundlePath]; bc.count++; } else { AssetBundle ab = AssetBundle.LoadFromFile(mainfestParentPath + "/" + bundlePath); bc = new BundleCounter(ab, 1, bundlePath); bundleDicts [bundlePath] = bc; } return(bc.asset); }
private IEnumerator LoadAssetBundleAsync(string bundlePath, System.Action <string, AssetBundle> act) { BundleCounter bc = null; if (bundleDicts.TryGetValue(bundlePath, out bc)) { bc = bundleDicts [bundlePath]; bc.count++; } else { AssetBundleCreateRequest request = AssetBundle.LoadFromFileAsync(mainfestParentPath + "/" + bundlePath); yield return(request); bc = new BundleCounter(request.assetBundle, 1, bundlePath); bundleDicts [bundlePath] = bc; } act(bundlePath, bc.asset); }