- Home /
AssetBundle.LoadFromFile throws exception instead of just returning null, why?
I want to try and load a resource from an external asset bundle, but, if that bundle is not available, I want to load from the internal Resource directory. According to the docs I should just be able to do this check:
// Load bundle into memory if exists.
ab = AssetBundle.LoadFromFile(extUrl);
if (null == ab) return false;
And single stepping over this code seems to work, but when I do a full run, Unity suddenly throws an undocumented exception and stops the run:
Unable to open archive file: <name>
UnityEngine.AssetBundle:LoadFromFile(String)
Capturing this exception doesn't work and although I can get around this in the editor by switching off Error Pause, that of course will mask all REAL errors. What am I doing wrong to cause loadfromfile to generate an exeption instead of just returning Null as it is supposed to?
Answer by liuyi1 · Jan 15, 2021 at 09:44 AM
I have met the same problem . It caused "Inflate Error: (file zip crc32 : 00000000) (result: fffffffb)" when using AssetBundle.LoadFromFile to load a bundle file which is not exsit in fact.
mLoadedBundle = AssetBundle.LoadFromFile(BundlePath);
if (mLoadedBundle == null)
{
Log.Error("Bundle LoadFromFile failed. " + BundlePath);
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612225628im_/https://answers.unity.com/themes/thub/images/avi.jpg)