static void Build(BuildTarget buildTarget) { string U3D_CODE_ROOT = Environment.GetEnvironmentVariable("U3D_CODE_ROOT"); string outputPath = Replace((U3D_CODE_ROOT + "/StreamingAssets/src")); string tempPath = Replace((U3D_CODE_ROOT + "/luaroot")); FileTool.CopyLuaFolderTo(Replace(U3D_CODE_ROOT + "/GameApp/Lua"), tempPath); FileTool.CopyLuaFolderTo(Replace(U3D_CODE_ROOT + "/Extends/Plugins/ToLua/Lua"), tempPath + "/tolua"); AssetDatabase.Refresh(); try { //检查是否存在目的目录 if (Directory.Exists(outputPath)) { FileTool.DeleteAll(outputPath); AssetDatabase.Refresh(); } Directory.CreateDirectory(outputPath); } catch (Exception e) { DebugManager.Log(e.Message); } //FileTool.CopyFolderTo(U3D_CODE_ROOT + "/GameApp/Lua", U3D_CODE_ROOT + "/StreamingAssets/src/lua"); //FileTool.CopyFolderTo(U3D_CODE_ROOT + "/GameApp/Lua", U3D_CODE_ROOT + "/StreamingAssets/src/lua"); FileTool.CopyFolderTo(U3D_CODE_ROOT + "/GameApp/Protobuf", U3D_CODE_ROOT + "/StreamingAssets/src/protobuf"); PackLuaDir(tempPath); //根据BuildSetting里面所激活的平台进行打包 BuildPipeline.BuildAssetBundles(outputPath, 0, buildTarget); AssetDatabase.Refresh(); //FileTool.DeleteAll(tempPath); //生成file文件 string filePaht = U3D_CODE_ROOT + "/StreamingAssets/file.t"; if (File.Exists(filePaht)) { File.Delete(filePaht); } StreamWriter streamWriter = File.CreateText(filePaht); writeFile(U3D_CODE_ROOT + "\\StreamingAssets", streamWriter, Replace(U3D_CODE_ROOT + "/StreamingAssets/")); streamWriter.Close(); //复制json文件 FileTool.CopyLuaFolderTo(tempPath + "/config/battleSkill", outputPath + "/gameapp/lua/battleskill"); //复制pb文件 Debug.Log("生成lua完成"); }