Question by
Mydila · Jan 04 at 02:58 AM ·
assetbundlemacosxcachecaching
Assetbundles freeze on load from cache
The huge freeze on loading assetbundles from cache (there is no freeze on first load from web). All of assetbundles are loading consistently. MacOS + Unity 2019.4.24f1
protected override async Task<UnityEngine.AssetBundle> LoadAssetFromCache(T info)
{
var cacheKey = _amazonS3Provider.GetAssetPath(info.CloudId, GetBundleType());
return await LoadBundleFile(info.DownloadUrl, cacheKey, info.CurrentHash);
}
private async Task<UnityEngine.AssetBundle> LoadBundleFile(string url, string cacheKey,
string downloadBundleHash)
{
if (string.IsNullOrEmpty(url))
{
throw new InvalidOperationException("bundle download url can not be null or empty");
}
if (string.IsNullOrEmpty(downloadBundleHash))
{
throw new InvalidOperationException("bundle hash can not be null or empty");
}
var uwr = new UnityWebRequest(
url,
"GET",
new DownloadHandlerAssetBundle(cacheKey, Hash128.Compute(downloadBundleHash), 0),
null
);
using (uwr)
{
await uwr.SendWebRequest();
if (uwr.isNetworkError || uwr.isHttpError)
{
throw new Exception($"Failed to download asset bundle, http code: {uwr.responseCode}");
}
var bundle = DownloadHandlerAssetBundle.GetContent(uwr);
if (bundle.IsObjectNull())
{
throw new Exception("Failed to download asset bundle, probably bundle with same file exists");
}
return bundle;
}
}
Comment
Your answer
Follow this Question
Related Questions
IOS/Android AssetBundle Cache Cleanup 0 Answers
Addressable Asset System 1 Answer
How can I cache an Addressable without loading it? 0 Answers