assetBundleName | AssetBundle 名称。 |
hash | 需要清除的版本。 |
bool 缓存清除成功时,返回 true。如果有任何缓存的 AssetBundle 处于使用状态,则返回 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));
}
}