- Home /
Unity AssetBundles error message
I have a Scene as a Unity "AssetBundle" to load, because this scene is well over 4GB in size and therefore no longer properly exported over the normal build.
The problem is, I always get an error message when loading the AssetBundle.
Error message: "Assertion failed: Assertion failed on expression: 'm_UncompressedBlocksOffsets [blockInd] <= from + dstPos && m_UncompressedBlocksOffsets [blockInd] + uncompressedBlockSize> = from + dstPos"
My script for loading AssetBundles:
IEnumerator SceneLoader()
{
var bundleRequest = AssetBundle.LoadFromFile(Path.Combine(Application.streamingAssetsPath, "gamescene"));
yield return bundleRequest;
if (bundleRequest == null)
{
Debug.LogError("AssetBundle could not be loaded!");
yield break;
}
SceneManager.LoadSceneAsync("GameScene");
}
Wouldn't you want to load your scene first, then load the assets into it? Rather than loading the assets then loading the scene. I dunno, it seems backwards.
Also, you don't need to use Path.Combine()
you can just use Application.strea$$anonymous$$gAssetsPath + "/gamescene"
. It's no big deal, but just looks nicer.
but I use a callback delegate to retrieve the asset bundle.
I do something like this :
public IEnumerator GetAsset(string bundleName, Action<AssetBundle> callback)
{
AssetBundle _bundle = AssetBundle.LoadFromFile(Application.strea$$anonymous$$gAssetsPath + "/" + bundleName);
// custom exception
if (_bundle == null)
{
Debug.LogError($"AssetBundles: Failed to load AssetBundle! '{bundleName}'");
yield break;
}
// calback
callback.Invoke(_bundle);
}
But I store all my assets in a aws-s3 bucket, so I don't actually get them from local disk. Little bit different. But the same logic applies.
I can not load the scene first, the scene is the asset bundle
Oh right, of course. Sorry, I forgot you could do that.
I think it might be because you're calling "GameScene" but need to call the complete path.
try using this code
string[] scenePaths = assetBundle.GetAllScenePaths();
string sceneName = System.IO.Path.GetFileNameWithoutExtension(scenePaths[0]);
Scene$$anonymous$$anager.LoadSceneAsync(sceneName);
But to be honest, I have no idea about that error message, never came across that before.
That does not work, I suspect it is due to this line: var bundleRequest = AssetBundle.LoadFromFile(Path.Combine(Application.strea$$anonymous$$gAssetsPath, "gamescene"));
Your answer
![](https://koobas.hobune.stream/wayback/20220612150435im_/https://answers.unity.com/themes/thub/images/avi.jpg)