- Home /
 
               Question by 
               Neroner  · Nov 02, 2015 at 06:38 PM · 
                assetbundleassetsfolder  
              
 
              Set AssetBundle name in Asset Labels of an folder
How to edit AssetBundle name of an folder, using C# ?
This can be done by simply selecting it from drop down list, but i would like to automate this...
Here is an SS
               Comment
              
 
               
                    string assetPath = AssetDatabase.GetAssetPath(yourGameObject);
      AssetImporter.GetAtPath(assetPath).SetAssetBundleNameAndVariant("somebundlename", "");
Answer by magnatua · Nov 03, 2015 at 05:24 PM
        AssetImporter assetImporter = AssetImporter.GetAtPath("Assets/Meshes/Maps/LevelName.unity");
             assetImporter.assetBundleName = "myLevel-scene";
             assetImporter.SaveAndReimport();
 
Even though, it's old question, answer is
 AssetImporter assetImporter = AssetImporter.GetAtPath("Assets/Meshes");
              assetImporter.assetBundleName = "myLevel-scene";
              assetImporter.SaveAndReimport();
For folder just give folder path,
Answer by seobyeongky · May 28, 2017 at 04:25 AM
Use AssetImporter.GetAtPath. This method works for directory.
Answer by nlisun · Aug 01, 2017 at 08:13 AM
      string assetPath = AssetDatabase.GetAssetPath(yourGameObject);
      AssetImporter.GetAtPath(assetPath).SetAssetBundleNameAndVariant("somebundlename", "");
It doesnt work in my case... i always get a NullReferenceException. i'm trying with the following code:
 foreach (string path in cleanPaths)
     {
         AssetImporter.GetAtPath(path).SetAssetBundleNameAndVariant("AB_01", "");
     }
while cleanPaths contains all paths to the folders i want to have in the same AB. i tripple checked them, the path look just as they should. Can anyone confirm this is still working in 2018.3?
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                