Documentation

Unity Engine

Download Unity

Unity Engine

ClearCache

Deletes all the AssetBundles stored in this cache.
Read time 1 minuteLast updated 12 days ago

Definition

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

ClearCache()

Deletes all the AssetBundles stored in this cache.
public bool ClearCache()

Returns

Type

Description

boolTrue if the cache was cleared. False if an AssetBundle from this cache is loaded, or if Unity can't delete the cache folder.

Remarks

If any AssetBundle from this cache is loaded, this method deletes nothing and returns false. Unload the AssetBundles first.
For a read-only cache, this method deletes no files and returns true.
Additional Resources: Caching.ClearCache.

ClearCache(int)

Deletes the AssetBundle versions in this cache that haven't been used for longer than the specified number of seconds.
public bool ClearCache(int expiration)

Parameters

expiration

Number of seconds since a version was last used, after which this method deletes it.

Returns

Type

Description

boolAlways true, even if this method deletes nothing, for example because every version was used recently or is loaded.

Remarks

A version counts as used when Unity downloads it, loads it from the cache, or when you pass it to Caching.MarkAsUsed. This method skips versions that are currently loaded.
When a cache is opened, at application startup or when you call Caching.AddCache, Unity deletes the versions in it that haven't been used for 150 days. Use this method to delete unused versions sooner.
Additional Resources: Caching.ClearCache.