- Home /
Question by
Waqark1103 · May 21, 2018 at 08:07 AM ·
prefabeditor-scriptingassetbundle
Add Asset Bundle Name to a prefab in "Editor Code"
Hello there,
I have an editor script - which gets all the selected prefabs from the Project Window using Selection.GetFiltered...
Then it exports it as asset bundle.
My query here is: Is it possible if we can provide asset bundle name to prefab in the code, before exporting using BuildPipeline.BuildAssetBundles, rather than in the editor?
Comment
Best Answer
Answer by Waqark1103 · May 24, 2018 at 01:47 AM
Alright, so I figured it out.
First, you need to extend your Editor Script class with AssetPostprocessor class.
Then the following code will do it for you:
AssetImporter.GetAtPath(sourcePath).SetAssetBundleNameAndVariant("asset_bundle_name", "variant_name");
where source Path = "Assets/PrefabFolder/PrefabName.prefab"