public static void SetAbLabel() { string needSetLabelRoot = PathTools.GetAbResourcesPath(); // Asset存储的根目录 DirectoryInfo[] resDirs = new DirectoryInfo(needSetLabelRoot).GetDirectories(); // 获取资源文件夹的所有子文件夹 AssetDatabase.RemoveUnusedAssetBundleNames(); // 清空所有的无用标记 foreach (DirectoryInfo resDir in resDirs) { // 遍历所有场景资源文件夹 DirectoryInfo tmpResDirInfo = new DirectoryInfo(resDir.FullName); // 分类文件夹的信息 string resDirName = resDir.FullName; // 资源文件夹的全称 #if UNITY_EDITOR_WIN resDirName = resDirName.Replace('\\', '/'); // Windows下将所有的\分隔符转为成/ #endif int tmpIndex = resDirName.LastIndexOf("/", StringComparison.Ordinal); // 场景名称字符串位置 string tmpSceneName = resDirName.Substring(tmpIndex + 1); // 场景名称 JudgeTypeByRecursive(tmpResDirInfo, tmpSceneName); // 递归调用判定方法 } AssetDatabase.Refresh(); // 刷新Project视图 Debug.Log("本次操作设置标记完成!"); // 提示打包完成信息 }