Version: 2017.3

Caching.IsVersionCached

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

参数

string Url - AssetBundle 的文件名。将自动剔除该字符串中的域和路径信息。
int Version - 要检查的 AssetBundle 的版本号。不允许使用负值。

返回

bool True if an AssetBundle matching the url and version parameters has previously been loaded using UnityWebRequest.GetAssetBundle() 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 播放器。