private void AutoGenAssetNameInFolder(string folderPath) { if (folderPath == null) { Log.w("Folder Path Is Null!"); return; } Log.i("Start Set Asset Name. Folder:" + folderPath); string workPath = EditorUtils.AssetsPath2ABSPath(folderPath).Replace("\\", "/"); //EditUtils.GetFullPath4AssetsPath(folderPath); string assetBundleName = EditorUtils.AssetPath2ReltivePath(folderPath).ToLower(); //EditUtils.GetReltivePath4AssetPath(folderPath).ToLower(); assetBundleName = assetBundleName.Replace("resources/", ""); //处理文件 var filePaths = Directory.GetFiles(workPath); ABConfigUnit configUnit = GetConfigUnit(workPath); bool isFolderFlag = true; if (configUnit != null) { isFolderFlag = configUnit.isFolderFlag; } for (int i = 0; i < filePaths.Length; ++i) { if (!AssetFileFilter.IsAsset(filePaths[i])) { continue; } string fileName = Path.GetFileName(filePaths[i]); string fullFileName = string.Format("{0}/{1}", folderPath, fileName); AssetImporter ai = AssetImporter.GetAtPath(fullFileName); if (ai == null) { Log.e("Not Find Asset:" + fullFileName); continue; } else { if (isFolderFlag) { ai.assetBundleName = assetBundleName + ".bundle"; } else { ai.assetBundleName = string.Format("{0}/{1}.bundle", assetBundleName, PathHelper.FileNameWithoutSuffix(fileName)); } } //ai.SaveAndReimport(); //Log.i("Success Process Asset:" + fileName); } //递归处理文件夹 var dirs = Directory.GetDirectories(workPath); for (int i = 0; i < dirs.Length; ++i) { string fileName = Path.GetFileName(dirs[i]); fileName = string.Format("{0}/{1}", folderPath, fileName); AutoGenAssetNameInFolder(fileName); } }