返回介绍

Caching.IsVersionCached 是否缓存版本

发布于 2019-12-18 15:37:27 字数 2396 浏览 1324 评论 0 收藏 0

JavaScript => public static function IsVersionCached(url: string, version: int): bool;
C# => public static bool IsVersionCached(string url, int version);

Parameters 参数

stringUrl The filename of the AssetBundle. Domain and path information are stripped from this string automatically.
intVersion The version number of the AssetBundle to check for. Negative values are not allowed.

Returns 返回

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.

Description 描述

Checks if an AssetBundle is cached.

检查资源包是否缓存。

When using the default shared cache, the URL of the WebPlayer application bundle is automatically prepended to the url parameter; this prevents filename collisions with identically-named AssetBundles used by other developers' WebPlayer applications. WebPlayer applications that use a dedicated cache do not experience this behavior. This function can be utilized to enable AssetBundle preloading. First, call Caching.IsVersionCached() to see if the current version of an AssetBundle is already cached. If the AssetBundle is not cached, it can be preloaded in the background so that it is immediately available for loading into memory when requested.

当使用默认共享缓存时,网页播放器应用包的URL自动预存url 参数;该预存目录名称和其他开发商的网页播放器应用的名称相同的资源包冲突。网页播放器应用使用专属缓存没有该行为。该功能可以被利用去启用预加载资源包。首先,调用Caching.IsVersionCached()去看是否当前版本的资源已经缓存。如果资源包没有被缓存,他可以被预先加载进背景因此当需要时可以立即加载进内存中。

JavaScript:

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

C#:

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

caching

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文