Version: 2017.2

Caching.IsVersionCached

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

参数

url The filename of the AssetBundle. Domain and path information are stripped from this string automatically.
version The version number of the AssetBundle to check for. Negative values are not allowed.
hash 用作 AssetBundle 版本的 Hash128。

返回

bool True if an AssetBundle matching the url and version parameters has previously been loaded using WWW.LoadFromCacheOrDownload() and is currently stored in the cache. Returns false if the AssetBundle is not in cache, either because it has been flushed from the cache or was never loaded using the Caching API.

描述

检查是否缓存了某个 AssetBundle。

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

if (Caching.IsVersionCached("http://myserver.com/bla.unity3d", 3))
    GUILayout.Button("Load Level");

5.4.0 及更高版本不支持 Web 播放器。