public static void AutoMark() { AssetDatabase.RemoveUnusedAssetBundleNames(); string needAutoMarkRoot = string.Empty; //根目录下 所有场景目录 DirectoryInfo[] dirScenensDir = null; //需要打包资源的文件夹根目录 needAutoMarkRoot = PathTools.GetABResourcesPath(); // DirectoryInfo directoryInfo = new DirectoryInfo(needAutoMarkRoot); dirScenensDir = directoryInfo.GetDirectories(); foreach (var currentDir in dirScenensDir) { string tempScenesDir = needAutoMarkRoot + "/" + currentDir.Name; int tempScenesIndex = tempScenesDir.LastIndexOf("/"); string tempScenesName = tempScenesDir.Substring(tempScenesIndex + 1); JudgeDirOrFile(currentDir, tempScenesName); } AssetDatabase.Refresh(); }
public static void SetABName() { AssetDatabase.RemoveUnusedAssetBundleNames(); string abResPath = string.Empty; abResPath = PathTools.GetABResourcesPath(); DirectoryInfo[] dirScenesArray = null; // 根目录下的所有一级子目录 DirectoryInfo dirTempInfo = new DirectoryInfo(abResPath); dirScenesArray = dirTempInfo.GetDirectories(); foreach (var item in dirScenesArray) { string tempSceneDir = abResPath + "/" + item.Name; // 全路径 //DirectoryInfo tempSceneDirInfo = new DirectoryInfo(tempSceneDir); int tempIndex = tempSceneDir.LastIndexOf("/"); string tempSceneName = tempSceneDir.Substring(tempIndex + 1); // 场景名称 JudgeDirOrFileRecursive(item, tempSceneName); } AssetDatabase.Refresh(); Debug.Log("AssetBundle 本次操作设置标记完成!"); }