[MenuItem("Assets/平台打包/清理AssetBundle名字")]
static public void ClearBundleFileName()
{
string path = Application.dataPath + "/Resources";
string[] files = System.IO.Directory.GetFiles( path, "*.*", SearchOption.AllDirectories);
if( ( files != null ) && ( files.Length > 0 ) )
{
for( int i = 0; i < files.Length; ++i )
{
string fileName = files[ i ];
string localPath = AssetBunbleInfo.GetLocalPath(fileName);
if( !string.IsNullOrEmpty( localPath ) )
{
localPath = localPath.ToLower();
}
if( AssetBundleBuild.FileIsResource( localPath ) )
{
AssetImporter importer = AssetImporter.GetAtPath(localPath);
if( importer != null )
{
importer.assetBundleName = string.Empty;
}
}
}
}
AssetDatabase.RemoveUnusedAssetBundleNames();
}
注意:localPath是Assets下的路径
比如:有个资源C://MyClinet/Assets/Resources/xxx.prefab。localPath就是:Assets/Resources/xxx.prefab
int length = AssetDatabase.GetAllAssetBundleNames().Length;
string[] oldAssetBundleNames = new string[length];
for (int i = 0; i < length; i++)
{
oldAssetBundleNames[i] = AssetDatabase.GetAllAssetBundleNames()[i];
}
for (int j = 0; j < oldAssetBundleNames.Length; j++)
{
AssetDatabase.RemoveAssetBundleName(oldAssetBundleNames[j], true);
}