I’ve been attempting to make use of asset bundles as part of my project, but for some reason unity is generating bundles that, when loading some (but not all) assets from the bundle, unity crashes.
I’m almost certain it’s a bug with unity, but searches for the error has returned nothing related on the internet. The objects in the bundle are simply prefabs with some serialized fields and references to sprites. It doesn’t seem to matter if the bundle is compressed or not. Changing or removing files from the bundle changes what assets cause unity to crash; there isn’t any single asset in particular causing it to crash. Below a certain number of assets I don’t seem to get a crash though.
I’ve tested in Unity 5.3.2, Unity 5.3.3p2, and even 5.4.0b8 and still no luck.
The editor log from the crash is as follows:
The code used to generate the asset bundle is fairly simple:
[MenuItem("Scripts/Generate Asset Bundles")]
static void MakeAssetBundles()
{
var assetNames = new List<string>();
foreach (var f in Directory.GetFiles("Assets/PrefabFolder/LayerPrefabs/texture-Animations2", "*.prefab"))
assetNames.Add(f);
var b = new AssetBundleBuild();
b.assetBundleName = "texture-animations2";
b.assetNames = assetNames.ToArray();
BuildPipeline.BuildAssetBundles("Assets/StreamingAssets", new []{b}, BuildAssetBundleOptions.UncompressedAssetBundle, BuildTarget.StandaloneWindows);
Debug.Log("Done");
}
As mentioned, though I specify uncompressed, this is mostly for time constraints. It still crashes with other bundle options.
And the code used to load the bundles to generate the crash is even simpler:
void Start()
{
var path = Path.Combine(Application.streamingAssetsPath, "texture-animations2");
var bundle = AssetBundle.LoadFromFile(path);
bundle.LoadAllAssets();
}
I’ve made a repo case and submitted it as a bug, case 776430. It’s not a small repo case though (250mb) as I needed a certain threshold of assets in order to generate a failing asset bundle, so I worry it will not get looked at in a timely fashion.
Anyone have any rough idea what could be causing this kind of failure? I’m at wits end.