Documentation

Unity Engine

Download Unity

Unity Engine

IsVersionCached

Checks if an AssetBundle is cached.
Read time 1 minuteLast updated 9 days ago

Definition

  • Type: Method
  • Namespace: UnityEngine
  • Assembly: UnityEngine.CoreModule

IsVersionCached(string, Hash128)

Checks if an AssetBundle is cached.
public static bool IsVersionCached(string url, Hash128 hash)

Parameters

The filename of the AssetBundle. Domain and path information are stripped from this string automatically.

The version hash of the AssetBundle to check for. Corresponds to the version hash in some signatures of UnityWebRequestAssetBundle.GetAssetBundle.

Returns

Type

Description

boolTrue if the AssetBundle version is stored in any cache in the cache list. False if it was never downloaded into a cache, or has since been deleted.

Remarks

Unity identifies a cached AssetBundle by its name and version hash. The name is the last part of
url
, without the file extension or query string. The rest of the URL is ignored, so two URLs that end in the same file name refer to the same cached AssetBundle. This method searches every cache in the cache list. 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.

IsVersionCached(CachedAssetBundle)

Checks if an AssetBundle is cached.
public static bool IsVersionCached(CachedAssetBundle cachedBundle)

Parameters

cachedBundle

A CachedAssetBundle struct that pairs the AssetBundle name with the version hash to check for.

Returns

Type

Description

boolTrue if the specified AssetBundle version is currently stored in the cache. Otherwise, false.