Caching.ClearAllCachedVersions

切换到手册
public static bool ClearAllCachedVersions (string assetBundleName);

参数

assetBundleNameAssetBundle 名称。

返回

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

描述

从缓存中删除给定 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); } }