Library for caching and unloading assets
Open the package manager window (menu: Window > Package Manager)
Select "Add package from git URL...", fill in the pop-up with the following link:
https://github.com/coryleach/UnityAssetCache.git#1.3.0
Find the manifest.json file in the Packages folder of your project and edit it to look like this:
{
"dependencies": {
"com.gameframe.assetcache": "https://github.com/coryleach/UnityAssetCache.git#1.3.0",
...
},
}
//Create an asset cache (like a WebTextureCache)
var cache = new WebTextureCache();
//Get a cached asset asynchronously
var cachedAsset = await cache.GetAsync(url);
//Use the asset
image.texture = cachedAsset.Asset;
//Dispose the reference so the cache knows you no longer are using it
cachedAsset.Dispose();
cachedAsset = null;
//Clean the cache so all assets with zero references are unloaded
cache.ClearUnusedAssets();
👤 Cory Leach
- Twitter: @coryleach
- Github: @coryleach
Give a ⭐️ if this project helped you!
Please consider supporting it either by contributing to the Github projects (submitting bug reports or features and/or creating pull requests) or by buying me coffee using any of the links below. Every little bit helps!
This README was generated with ❤️ by Gameframe.Packages