A lightweight Addressables handle cache for Unity.
Laurier Asset Handle Cache provides a simple way to cache AsyncOperationHandles,
prevent duplicate asset loading, and manage loaded assets by scope.
- Cache
AsyncOperationHandles automatically - Prevent duplicate loads of the same asset
- Scope-based lifetime management
- Release individual assets
- Release all assets in a scope
- Release every cached asset
- Thin wrapper around Unity Addressables
[SerializeField]privateAssetReferenceGameObjectplayerPrefab;varhandle=AssetHandleCache.Load<GameObject>(playerPrefab);awaithandle.Task;Instantiate(handle.Result);Loading the same asset again returns the cached handle.
varhandle1=AssetHandleCache.Load<GameObject>(playerPrefab);varhandle2=AssetHandleCache.Load<GameObject>(playerPrefab);// Same underlying AsyncOperationHandleAssets can be grouped into scopes.
AssetHandleCache.Load<GameObject>(enemyPrefab,"Battle");AssetHandleCache.Load<AudioClip>(bgm,"Battle");Release every asset in the scope.
AssetHandleCache.ReleaseScope("Battle");Release a single asset.
AssetHandleCache.Release(playerPrefab);Release every cached asset.
AssetHandleCache.ReleaseAll();Unload unused Unity assets.
awaitAssetHandleCache.UnloadUnusedAssets();- Loading the same
AssetReferencemultiple times returns the cached handle. - Assets are identified by their
AssetGUID. UnloadUnusedAssets()only callsResources.UnloadUnusedAssets().- Remember to release assets when they are no longer needed.
zlib/libpng License