//[MenuItem("Hugula/export config [Assets\\Config]", false, 13)] public static void exportConfig() { string path = Application.dataPath + "/Config"; //AssetDatabase.GetAssetPath(obj).Replace("Assets",""); List <string> files = getAllChildFiles(path + "/", "csv"); string assetPath = "Assets/Config"; List <UnityEngine.Object> res = new List <Object>(); foreach (string name in files) { string abPath = assetPath + name.Replace(path, ""); Debug.Log(abPath); Object txt = AssetDatabase.LoadAssetAtPath(abPath, typeof(TextAsset)); res.Add(txt); } string cname = "/font1.u3d"; string outPath = ExportAssetBundles.GetOutPath(); string tarName = outPath + cname; Object[] ress = res.ToArray(); Debug.Log(ress.Length); ExportAssetBundles.BuildAB(null, ress, tarName, BuildAssetBundleOptions.CompleteAssets); Debug.Log(tarName + " export"); }
//[MenuItem("Hugula/export language [Assets\\Lan]", false, 14)] public static void exportLanguage() { string assetPath = "Assets/Lan/"; string path = Application.dataPath + "/Lan/"; //AssetDatabase.GetAssetPath(obj).Replace("Assets",""); List <string> files = getAllChildFiles(path, "csv"); foreach (string name in files) { string abPath = assetPath + name.Replace(path, ""); Debug.Log(abPath); Object txt = AssetDatabase.LoadAssetAtPath(abPath, typeof(TextAsset)); string cname = txt.name; string outPath = ExportAssetBundles.GetOutPath(); string tarName = outPath + "/Lan/" + cname + "." + Common.LANGUAGE_SUFFIX; CheckDirectory(Application.streamingAssetsPath + "/" + ExportAssetBundles.GetTarget().ToString() + "/Lan/"); ExportAssetBundles.BuildAB(txt, null, tarName, BuildAssetBundleOptions.CompleteAssets); } }
//[MenuItem("Hugula/export lua [Assets\\Lua]", false, 12)] public static void exportLua() { checkLuaExportPath(); string path = Application.dataPath + "/Lua"; //AssetDatabase.GetAssetPath(obj).Replace("Assets",""); List <string> files = getAllChildFiles(path); // Directory.GetFiles(Application.dataPath + path); IList <string> childrens = new List <string>(); foreach (string file in files) { if (file.EndsWith("lua")) { childrens.Add(file); } } Debug.Log("luajit path = " + luacPath); string crypName = "", fileName = "", outfilePath = "", arg = ""; System.Text.StringBuilder sb = new System.Text.StringBuilder(); DirectoryDelete(Application.dataPath + OutLuaPath); foreach (string filePath in childrens) { fileName = CUtils.GetURLFileName(filePath); //crypName=CryptographHelper.CrypfString(fileName); crypName = filePath.Replace(path, "").Replace(".lua", "." + Common.LUA_LC_SUFFIX).Replace("\\", "/"); outfilePath = Application.dataPath + OutLuaPath + crypName; checkLuaChildDirectory(outfilePath); sb.Append(fileName); sb.Append("="); sb.Append(crypName); sb.Append("\n"); #if Nlua || UNITY_IPHONE arg = "-o " + outfilePath + " " + filePath; File.Copy(filePath, outfilePath, true); #else arg = "-b " + filePath + " " + outfilePath; //for jit Debug.Log(arg); System.Diagnostics.Process.Start(luacPath, arg);//arg -b hello1.lua hello1.out #endif } Debug.Log(sb.ToString()); Debug.Log("lua:" + path + "files=" + files.Count + " completed"); System.Threading.Thread.Sleep(1000); AssetDatabase.Refresh(); //打包成assetbundle string luaOut = Application.dataPath + OutLuaPath; Debug.Log(luaOut); List <string> luafiles = getAllChildFiles(luaOut + "/", Common.LUA_LC_SUFFIX); string assetPath = "Assets" + OutLuaPath; List <UnityEngine.Object> res = new List <Object>(); string relatePathName = ""; foreach (string name in luafiles) { relatePathName = name.Replace(luaOut, ""); string abPath = assetPath + relatePathName; Debug.Log(abPath); Debug.Log(relatePathName); Object txt = AssetDatabase.LoadAssetAtPath(abPath, typeof(TextAsset)); txt.name = relatePathName.Replace(@"\", @".").Replace("/", "").Replace("." + Common.LUA_LC_SUFFIX, ""); Debug.Log(txt.name); res.Add(txt); } string cname = "/luaout.bytes"; string outPath = luaOut; //ExportAssetBundles.GetOutPath(); string tarName = outPath + cname; Object[] ress = res.ToArray(); Debug.Log(ress.Length); ExportAssetBundles.BuildAB(null, ress, tarName, BuildAssetBundleOptions.CompleteAssets); // Debug.Log(tarName + " export"); AssetDatabase.Refresh(); //Directory.CreateDirectory(luaOut); string realOutPath = ExportAssetBundles.GetOutPath() + "/font.u3d"; byte[] by = File.ReadAllBytes(tarName); Debug.Log(by); byte[] Encrypt = CryptographHelper.Encrypt(by, GetKey(), GetIV()); File.WriteAllBytes(realOutPath, Encrypt); Debug.Log(realOutPath + " export"); }