Problem loading asset bundles with our own caching mechanism
I'm trying to use asset bundles with my own caching and loading. The process of downloading and writing works fine:
using (var www = new WWW(url)){
....
File.WriteAllBytes(bundlesFolder + bundleName, www.bytes);
}
The issue is with the loading. I've tried using File class:
byte[] bytes = File.ReadAllBytes(bundlesFolder + localBundlePath);
AssetBundle bundle = AssetBundle.CreateFromMemoryImmediate(bytes);
I've tried "using www" encapsulating:
AssetBundle bundle = null;
using (WWW www = new WWW("file://" + bundlesFolder + localBundlePath))
{
yield return www;
if (!string.IsNullOrEmpty((www.error)))
{
log.ErrorFormat("WWW Error: {0}", www.error);
}
else
{
bundle = www.assetBundle;
}
}
The problem is that on large asset bundles (>10MB), the code above causes iOS to crash due to high memory usage. Loading the exact same file using WWW.LoadFromCacheOrDownload
on the same device does not crash.
using (WWW www = WWW.LoadFromCacheOrDownload ("file://" + bundlesFolder + localBundlePath))
....
What am I doing wrong? Are there other ways to load the bundles from a local file?
(AssetBundle.CreateFromMemory
doesn't help either. And AssetBundle.CreateFromFile
isn't an option since our bundles are compressed (we use the deterministic option))
Your answer

Follow this Question
Related Questions
Assetbundles freeze on load from cache 0 Answers
How can I cache an Addressable without loading it? 0 Answers
IOS/Android AssetBundle Cache Cleanup 0 Answers