private static void SetupAssetBundleNames(DirectoryInfo directoryInfo, bool clear = false) { FileInfo[] fileInfos = directoryInfo.GetFiles(); for (int cnt = 0; cnt < fileInfos.Length; cnt++) { if (AssetBundleExtension.IsLegal(fileInfos[cnt].Extension)) { string assetbundleName = directoryInfo.FullName; if (clear) { assetbundleName = ""; } else { assetbundleName = assetbundleName.Replace(Path.Combine(Application.dataPath, ASSET_BUNDLE_RESOURCE_FOLDER), "") + "/" + fileInfos[cnt].Name.Substring(0, fileInfos[cnt].Name.Length - 4) + ".assetbundle"; assetbundleName = assetbundleName.ToLower(); } string filePath = fileInfos[cnt].FullName; if (clear) { filePath = filePath.Replace(Application.dataPath, ""); filePath = "Assets" + filePath; } else { filePath = filePath.Replace(Path.Combine(Application.dataPath, ASSET_BUNDLE_RESOURCE_FOLDER), ""); filePath = Path.Combine(ASSET_BUNDLE_RESOURCE_FOLDER, filePath); filePath = Path.Combine("Assets", filePath); } AssetImporter.GetAtPath(filePath).assetBundleName = assetbundleName; // if (clear) // { // Debug.Log (string.Format ("Clear the asset \"{0}\" assetBundleName", filePath)); // } // else // { // Debug.Log (string.Format("Set the asset \"{0}\" assetBundleName to {1}", fileInfos[cnt].Name, assetbundleName)); // } } } DirectoryInfo[] directoryInfos = directoryInfo.GetDirectories(); if (directoryInfos.Length != 0) { for (int cnt = 0; cnt < directoryInfos.Length; cnt++) { SetupAssetBundleNames(directoryInfos[cnt], clear); } } }
private static void GetAllAssetBundlePath(List <string> allFiles, DirectoryInfo directoryInfo) { FileInfo[] fileInfos = directoryInfo.GetFiles(); for (int cnt = 0; cnt < fileInfos.Length; cnt++) { if (AssetBundleExtension.IsLegal(fileInfos[cnt].Extension)) { allFiles.Add(fileInfos[cnt].FullName.Replace(ASSET_BUNDLE_RESOURCE_FOLDER, "").Replace(fileInfos[cnt].Extension, "")); } } DirectoryInfo[] directoryInfos = directoryInfo.GetDirectories(); if (directoryInfos.Length != 0) { for (int cnt = 0; cnt < directoryInfos.Length; cnt++) { GetAllAssetBundlePath(allFiles, directoryInfos[cnt]); } } }