Caching.ClearAllCachedVersions

Switch to Manual
public static bool ClearAllCachedVersions (string assetBundleName);

Parameters

assetBundleNameAssetBundle 名称。

Returns

bool 缓存清除成功时,返回 true。

Description

从缓存中删除给定 AssetBundle 的所有缓存版本。

如果有任何缓存的 AssetBundle 处于使用状态,则返回 false。

using System.Collections;
using UnityEngine.Networking;
using UnityEngine;

public class Example : MonoBehaviour { IEnumerator ClearAllCachedVersionsExample(string uri) { //Download the bundle UnityWebRequest request = UnityWebRequestAssetBundle.GetAssetBundle(uri); yield return request.SendWebRequest(); AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(request);

//Given the name of an asset bundle, this will clear every cached version across all caches Caching.ClearAllCachedVersions(bundle.name); } }