public static void BuildAB() { //AB包输出路径 string abOutPath = BuildABPath.GetABOutPath(); //判断输出目录是否存在 if (!Directory.Exists(abOutPath)) { Directory.CreateDirectory(abOutPath); } //获取打包平台 BuildTarget target = BuildTarget.NoTarget; switch (BuildABPath.GetPlatformName()) { case "Android": target = BuildTarget.Android; break; case "Windows": target = BuildTarget.StandaloneWindows64; break; case "IOS": target = BuildTarget.iOS; break; } //打包生成 BuildPipeline.BuildAssetBundles(abOutPath, BuildAssetBundleOptions.None, target); //刷新 AssetDatabase.Refresh(); }
public static void DelAssetBundle() { string path = BuildABPath.GetABOutPath(); Directory.Delete(path, true); File.Delete(path + ".meta"); AssetDatabase.Refresh(); }
public static void SetABLabel() { //清空无用标记 AssetDatabase.RemoveUnusedAssetBundleNames(); //获取需要给AB做标记的资源根目录信息 string needSetLabelRoot = BuildABPath.GetABResPath(); DirectoryInfo tempInfo = new DirectoryInfo(needSetLabelRoot); //获取根目录下所有一级目录 DirectoryInfo[] firstDirArray = tempInfo.GetDirectories(); //遍历所有一级目录 foreach (DirectoryInfo currentDir in firstDirArray) { //递归 JudgeDIRorFileByRecursisve(currentDir, currentDir.Name); } //刷新并提示 AssetDatabase.Refresh(); Debug.Log("标记结束"); }