Assigning Asset Bundle in Script

I’m trying to assign scenes to asset bundles in an editor script. I searched around online and saw that you can edit the asset bundle of an asset by using:

		Scene scene = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Additive);
		EditorSceneManager.SaveScene(scene, scenePath);
		EditorSceneManager.CloseScene(scene, true);
		EditorApplication.SaveAssets();

		AssetImporter assetImporter = AssetImporter.GetAtPath(scenePath);
		assetImporter.assetBundleName = chunkName;
		assetImporter.SaveAndReimport();

Unforunately this doesn’t appear to work for scenes (it did work for TerrainData), ‘assetImporter’ becomes null.

It does work for scenes. Read this, and download the sample project:

Also read this (maybe even before the tutorial):

http://forum.unity3d.com/threads/the-assetbundle-manager-tutorial-q-a.354400/

Good Luck!

The question was regarding how to assign the bundle IDs to scenes from a script. The tutorial does not mention how this is possible. This question is still open.