Version: 2023.1

Caching.IsVersionCached

切换到手册
public static bool IsVersionCached (string url, Hash128 hash);
Obsolete public static bool IsVersionCached (string url, int version);

参数

Url The filename of the AssetBundle. Domain and path information are stripped from this string automatically.
hash The version hash of the AssetBundle to check for. Corresponds to the version hash in some signatures of UnityWebRequestAssetBundle.GetAssetBundle.
version The version number of the AssetBundle to check for. Corresponds to the numeric version in some signatures of UnityWebRequestAssetBundle.GetAssetBundle.

返回

bool 如果以前使用 UnityWebRequestAssetBundle.GetAssetBundle() 加载过匹配 urlversion 参数的 AssetBundle,并且该 AssetBundle 当前存储在该缓存中,则返回 true。如果 AssetBundle 不在缓存(不管是已将其从缓存中清除还是从未使用缓存 API 加载过它)中,则返回 false。

描述

检查是否缓存了某个 AssetBundle。

使用默认共享缓存时,会自动在 url 参数前插入 WebPlayer 应用程序捆绑包的 URL;这可防止文件名与其他开发人员的 WebPlayer 应用程序使用的同名 AssetBundle 发生冲突。使用专用缓存的 WebPlayer 应用程序不会遇到这种行为。 该函数可用于启用 AssetBundle 预加载。首先,调用 Caching.IsVersionCached() 查看是否已缓存 AssetBundle 的当前版本。如果未缓存 AssetBundle,则可以在后台预加载它,以便在请求时能够立即将其加载到内存中。