- Home /
Can I create asset bundles dynamically in Unity 5?
I worked in a project in Unity 4.5 where I had to put assets in asset bundles and upload them to a database to be downloaded later by the game. I had a tool that did that for me automatically, I could just drag assets to an editor window and it would create/upload the bundle for me. Now with the new asset bundle system I can't find a way to do the same. Can I create bundle dynamically through code or the editor is the only way? If that's not possible, can I at least put assets into an asset bundle dynamically? (My idea is to have a single asset bundle and export it with different names).
If none of that works, is there an alternative doing everything by hand?
Does this question answer yours ? creating-assetbundles-entirely-in-code-in-5x
Not really, I needed code examples and Unity's doc was the first place I looked
That's not what I needed though. I posted an answer with what I found.
Answer by LukeBitts · Jul 29, 2015 at 07:45 PM
var importer = AssetImporter.GetAtPath (AssetDatabase.GetAssetPath("..."));
importer.assetBundleName = "bundleName";
AssetDatabase.ImportAsset (AssetDatabase.GetAssetPath("..."));
This is what worked for me.