Skip to content

Instantly share code, notes, and snippets.

@kiyoaki
Created May 21, 2015 03:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kiyoaki/e239fac49180ba625257 to your computer and use it in GitHub Desktop.
Save kiyoaki/e239fac49180ba625257 to your computer and use it in GitHub Desktop.
How to set AssetBundleName from editor scripts.
public class AssetBundleNameGenerator
{
[MenuItem("AssetBundles/Set XXX")]
public static void SetXXX()
{
foreach (var file in Directory
.GetFiles("Assets/XXX/XXX/",
"*.xxx", SearchOption.TopDirectoryOnly))
{
var importer = AssetImporter.GetAtPath(file);
var fileNameWithoutExt = Path.GetFileNameWithoutExtension(file);
var assetBundleName = "xxx/xxx/" + fileNameWithoutExt;
if (importer.assetBundleName == assetBundleName)
{
continue;
}
importer.assetBundleName = assetBundleName;
importer.SaveAndReimport();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment