assetBundleName | AssetBundle 名称。 |
hash | 需要清除的版本。 |
当缓存清除成功时,布尔值 返回 true。如果任何已缓存的包正在使用中,则返回 false。
移除给定版本的 AssetBundle。
using UnityEngine;
public class Example : MonoBehaviour { void ClearAssetBundleBundleFromCache(AssetBundle bundleToClear, string manifestBundlePath) { AssetBundle manifestBundle = AssetBundle.LoadFromFile(manifestBundlePath); AssetBundleManifest manifest = manifestBundle.LoadAsset<AssetBundleManifest>("AssetBundleManifest");
//This will clear the cached version from all caches, not just the currentCacheForWriting Caching.ClearCachedVersion(bundleToClear.name, manifest.GetAssetBundleHash(bundleToClear.name));
//Unload the AssetBundle manifestBundle.Unload(true); } }