private static void BuildScene(KTBundleConfig bundleConfig) { var tools = CreateInstance <KTBuildTools>(); string[] levels = { "Assets/" + tools.GetDstPath() + ".unity" }; BuildPipeline.BuildPlayer(levels, Path.Combine(tools.GetDstPath(), "scene.bundle"), BuildTarget.StandaloneWindows64, BuildOptions.BuildAdditionalStreamedScenes); AssetDatabase.Refresh(); }
/// <summary> /// 打包BundleConfig文件中的内容 /// 如果是bundle模式,则收集lua数据到bundleConfig中一起打包,否则直接拷贝lua根目录到目标目录 /// </summary> private static void BuildLua(KTBundleConfig bundleConfig) { //拷贝lua文件到临时目录,把所有lua文件后缀改为bytes,以便可以打进bundle包 var srcRoot = Path.Combine(Application.dataPath, KTConfigs.kLuaCodeDir); var tmpRoot = Path.Combine(Application.dataPath, KTConfigs.kLuaTempDir); List <string> luaDirs = new List <string>(); ListDirs(srcRoot, luaDirs); luaDirs.ForEach(dir => { var newDir = dir.Replace(srcRoot, tmpRoot); if (!Directory.Exists(newDir)) { Directory.CreateDirectory(newDir); } }); luaDirs.ForEach(dir => { var files = Directory.GetFiles(dir, "*.lua"); files.ToList().ForEach(file => File.Copy(file, file.Replace(srcRoot, tmpRoot).Replace(KTConfigs.kLuaExt, KTConfigs.kLuaBytesExt), true)); }); Debug.Log("copy lua files to temp folder finished"); //统计lua文件进KTAssetBundleBuild信息 luaDirs.Clear(); ListDirs(tmpRoot, luaDirs); List <string> luaFiles = new List <string>(); luaDirs.ForEach(dir => { var files = Directory.GetFiles(dir, "*.bytes").Select(file => { return(("Assets" + file.Replace(Application.dataPath, "")).Replace("\\", "/").Replace(KTConfigs.kLuaExt, KTConfigs.kLuaBytesExt)); }); luaFiles.AddRange(files); }); if (luaFiles.Count > 0) { KTBundleConfig.KTAssetBundleBuild abb = new KTBundleConfig.KTAssetBundleBuild() { assetBundleName = "lua.bundle", assetNames = (string[])luaFiles.ToArray().Clone(), addressableNames = luaFiles.Select(name => { return(name.Replace("Assets/Temp/", "").Replace(KTConfigs.kLuaBytesExt, "")); }).ToArray() }; bundleConfig.assetBundleBuildList.Add(abb); EditorUtility.SetDirty(bundleConfig); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } Debug.Log("bundle lua files finished"); }
/// <summary> /// 特效包,包括动画,模型,材质,贴图 /// </summary> private static void BuildParticle(KTBundleConfig bundleConfig) { }
/// <summary> /// 关卡相关,场景,模型,材质,贴图,光照贴图、寻路数据等 /// </summary> private static void BuildLevel(KTBundleConfig bundleConfig) { }
/// <summary> /// 打包音乐,音效,大型音乐可能要分包打 /// </summary> private static void BuildAudio(KTBundleConfig bundleConfig) { }
/// <summary> /// 公用图集一起打包(UIAtlas.prefab、UIAtlas.mat、UIAtlas.png)在进入游戏的时候加载并且常驻内存,属于公共依赖包 /// 单独的UI可能还要单独打包,每个单独的UI,可能包括prefab,mat,png等等 /// </summary> private static void BuildUI(KTBundleConfig bundleConfig) { }
/// <summary> /// 自定义shader,属于公共依赖包 /// </summary> private static void BuildShaders(KTBundleConfig bundleConfig) { }