Creating AssetBundles entirely in code in 5.x

I am upgrading my project from 4.6 to 5.1. It uses AssetBundels and I have an editor window to create these AssetBundles.

But the code is obsolete:

BuildPipeline.BuildAssetBundle(null,
     assets.ToArray(),
     path + item.GetValue("id"),
     BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets,
     BuildTarget.WebPlayer);

I understand how the new system works. But I don’t want to set everything up in my editor window and then manually set everything for the assetbundles again in the editor (my script also makes JSON with various information that cannot be stored in an asset bundle, so that still has to be done).

Is there a way to do all the settings through code?

Hello,

The Unity documentation answers this problem in a certain way :
Assetbundle Build Documentation

What you have to do is creating an AssetBundleBuild variable which contains all assets informations you need to create your assetbundle (which was your assets.ToArray() ) and then use the new assetbundle build method BuildPipeline.BuildAssetBundles(string outputPath, AssetBundleBuild builds)

Hope it helps :slight_smile:

This may as well help some other readers that want to do that from Node.js : GitHub - mitmadness/AssetBundleCompiler: 📦 Node.js wrapper around Unity3D's BuildPipeline to create AssetBundles from any files