public static void BuildAssetBundleLua() { checkLuaExportPath(); string path = Application.dataPath + "/LuaScripts/"; //lua path 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(); //refresh directory DirectoryDelete(Application.dataPath + OutLuaPath); CheckDirectory(Application.dataPath + OutLuaPath); List <string> exportNames = new List <string>(); foreach (string filePath in childrens) { fileName = Utils.GetURLFileName(filePath); crypName = filePath.Replace(path, "") .Replace(".lua", "." + Common.LUA_LC_SUFFIX) .Replace("\\", "_") .Replace("/", "_"); outfilePath = Application.dataPath + OutLuaPath + crypName; exportNames.Add("Assets" + OutLuaPath + crypName); sb.Append(fileName); sb.Append("="); sb.Append(crypName); sb.Append("\n"); #if Nlua || UNITY_IPHONE arg = "-o " + outfilePath + " " + filePath; // luac File.Copy(filePath, outfilePath, true); // source code copy #else arg = "-b " + filePath + " " + outfilePath; //for jit //Debug.Log(arg); //System.Diagnostics.Process.Start(luacPath, arg);//jit File.Copy(filePath, outfilePath, true); // source code copy #endif } Debug.Log("lua:" + path + "files=" + files.Count + " completed"); System.Threading.Thread.Sleep(1000); AssetDatabase.Refresh(); //u5 打包 string outPath = ExportAssetBundles.GetOutPath(); CheckDirectory(Application.dataPath.Replace("Assets", "") + outPath); ExportAssetBundles.BuildABs(exportNames.ToArray(), "Assets" + OutLuaPath, "luaout.bytes", BuildAssetBundleOptions.CompleteAssets); //Encrypt string tarName = Application.dataPath + OutLuaPath + "luaout.bytes"; string realOutPath = ExportAssetBundles.GetOutPath() + "/font.u3d"; byte[] by = File.ReadAllBytes(tarName); //byte[] Encrypt = CryptographHelper.Encrypt (by, GetKey (), GetIV()); File.WriteAllBytes(realOutPath, by); Debug.Log(realOutPath + " export"); }