public static void ExportPublic() { ExportAssetBundle.BuildAssetBundles(); AssetDatabase.Refresh(); ExportAssetBundle.ExportLua(); AssetDatabase.Refresh(); ExportAssetBundle.GenerateResPublic(CurrentBundleVersion.versionCode.ToString()); }
public static void ExportAllAssetBundle() { string strOutputPath = Path.GetFullPath(Path.Combine(Application.streamingAssetsPath, PathUtil.Platform)); DirectoryInfo dir = new DirectoryInfo(strOutputPath); if (dir.Exists) { dir.Delete(true); } ExportAssetBundle.BuildAssetBundles(); ExportAssetBundle.ExportLua(); }
public static void ExportLuaEx(string dirPath) { string tmpPath = Path.GetFullPath(Path.Combine(Application.dataPath, "tmp")); DirectoryDelete(tmpPath); CheckDirectory(tmpPath); string[] include = new string[] { ".lua", ".cs", ".txt", ".shader", ".py" }; List <string> exportNames = new List <string>(); string[] fileList = Directory.GetFiles(dirPath, "*.*", SearchOption.AllDirectories); for (int i = 0; i < fileList.Length; i++) { string fileName = fileList[i]; string ext = Path.GetExtension(fileName); if (Array.IndexOf <string>(include, ext) != -1) { string byteFileName = fileName.Replace(dirPath, ""); if (byteFileName.StartsWith("\\")) { byteFileName = byteFileName.Substring(1); } byteFileName = byteFileName.Replace("\\", "%").Replace("/", "%").Replace(".", "%"); byteFileName += ".bytes"; exportNames.Add("Assets/tmp/" + byteFileName); File.Copy(Path.GetFullPath(fileName), Path.Combine(tmpPath, byteFileName), true); } } System.Threading.Thread.Sleep(1000); AssetDatabase.Refresh(); ExportAssetBundle.BuildAssetBundles(exportNames.ToArray(), "Assets/tmp", "luaout.bytes", BuildAssetBundleOptions.DeterministicAssetBundle); string strOutputPath = Path.Combine(Application.streamingAssetsPath, PathUtil.Platform); CheckDirectory(strOutputPath); string luaoutPath = Path.Combine(Application.dataPath, "tmp/luaout.bytes"); string luaExportPath = Path.GetFullPath(Path.Combine(strOutputPath, "lua_core.u3d")); byte[] by = File.ReadAllBytes(luaoutPath); byte[] encrypt = CryptographHelper.Encrypt(by, key, iv); File.WriteAllBytes(luaExportPath, encrypt); DirectoryDelete(tmpPath); Debug.Log(luaExportPath + " export."); System.Threading.Thread.Sleep(100); AssetDatabase.Refresh(); }
private static void GenericBuild(string[] scenes, string target_dir, BuildTarget build_target, BuildOptions build_options) { AssetDatabase.Refresh(); bool needEncrypt = false; if (needEncrypt) { string strOutputPath = Path.GetFullPath(Path.Combine(Application.streamingAssetsPath, PathUtil.Platform)); DirectoryInfo dir = new DirectoryInfo(strOutputPath); if (dir.Exists) { dir.Delete(true); } AssetDatabase.Refresh(); GenerateObfuscatedCode.GenerateCodes(); AssetDatabase.Refresh(); } ExportAssetBundle.BuildAssetBundles(); ExportAssetBundle.ExportLua(); if (needEncrypt) { ExportAssetBundle.EncryptAssetBundle(); } ExportAssetBundle.GenerateVersion(); BuildReport res = BuildPipeline.BuildPlayer(scenes, target_dir, build_target, build_options); BuildSummary summary = res.summary; if (summary.result == BuildResult.Failed) { throw new Exception("BuildPlayer failure: " + res.ToString()); } }
public static void BuildAssetBundles() { ExportAssetBundle.BuildAssetBundles(); }
public static void ExportiPhonePublic(string subBucket = null) { string[] args = System.Environment.GetCommandLineArgs(); if (args == null || args.Length == 0) { return; } Debug.Log("ExportiPhonePublic: " + string.Join(", ", args)); List <string> fileList = new List <string>(); List <string> versionList = new List <string>(); Regex regExp = new Regex(@"^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$"); foreach (string fileName in args) { if (fileName.EndsWith(".u3d")) { fileList.Add(fileName); } else { if (regExp.IsMatch(fileName)) { string bundleVersionCode = BundleVersionChecker.BundleVersion2Code(fileName); if (!versionList.Contains(bundleVersionCode)) { versionList.Add(bundleVersionCode); } } } } EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.iOS, BuildTarget.iOS); string bundleVersion = args[args.Length - 3]; PlayerSettings.bundleVersion = bundleVersion; PlayerSettings.iOS.buildNumber = args[args.Length - 2]; BundleVersionChecker.UpdateBundleVersion(); AssetDatabase.Refresh(); ExportAssetBundle.BuildAssetBundles(); AssetDatabase.Refresh(); ExportAssetBundle.ExportLua(); AssetDatabase.Refresh(); string folder = args[args.Length - 1]; foreach (string bundleVersionCode in versionList) { string outFolderName = PathUtil.Platform + bundleVersionCode; if (!string.IsNullOrEmpty(subBucket)) { outFolderName = subBucket + "/" + outFolderName; } string strOut = Path.GetFullPath(Path.Combine(folder, outFolderName)); if (Directory.Exists(strOut) == false) { Directory.CreateDirectory(strOut); } Debug.Log("资源导出目录:" + strOut); ExportAssetBundle.GenerateResPublic(bundleVersionCode, strOut, fileList.ToArray()); } }
public static void ExportAndroidLuaPublic(string subBucket = null) { string[] args = System.Environment.GetCommandLineArgs(); if (args == null || args.Length == 0) { return; } Debug.Log(string.Join(",", args)); List <string> fileList = new List <string>(); List <string> versionList = new List <string>(); Regex regExp = new Regex(@"^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$"); foreach (string fileName in args) { if (fileName.EndsWith(".u3d")) { fileList.Add(fileName); } else { if (regExp.IsMatch(fileName)) { string bundleVersionCode = BundleVersionChecker.BundleVersion2Code(fileName); if (!versionList.Contains(bundleVersionCode)) { versionList.Add(bundleVersionCode); } } } } EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Android, BuildTarget.Android); //PlayerSettings.bundleIdentifier = "xin.unwrap.xiami"; string bundleVersion = args[args.Length - 2]; PlayerSettings.bundleVersion = bundleVersion; //PlayerSettings.SetPropertyInt("ScriptingBackend", (int)ScriptingImplementation.IL2CPP, BuildTarget.Android); BundleVersionChecker.UpdateBundleVersion(); AssetDatabase.Refresh(); ExportAssetBundle.BuildAssetBundles(); AssetDatabase.Refresh(); ExportAssetBundle.ExportLua(); AssetDatabase.Refresh(); string folder = args[args.Length - 1]; foreach (string bundleVersionCode in versionList) { string outFolderName = PathUtil.Platform + bundleVersionCode; if (!string.IsNullOrEmpty(subBucket)) { outFolderName = subBucket + "/" + outFolderName; } string strOut = Path.GetFullPath(Path.Combine(folder, outFolderName)); if (Directory.Exists(strOut) == false) { Directory.CreateDirectory(strOut); } Debug.Log("导出目录:" + strOut); ExportAssetBundle.GenerateDataPublic(strOut, fileList.ToArray()); } }
public static void ExportLua() { string path = Path.GetFullPath(Path.Combine(Application.dataPath, "Lua")); string tmpPath = Path.GetFullPath(Path.Combine(Application.dataPath, "tmp")); DirectoryDelete(tmpPath); CheckDirectory(tmpPath); List <string> sourceFiles = new List <string>(); List <string> exportNames = new List <string>(); List <string> files = getAllChildFiles(path, "lua"); foreach (string filePath in files) { string file = Path.GetFullPath(filePath); if (!file.EndsWith(".lua")) { continue; } string byteFileName = file.Replace(path, ""); if (byteFileName.StartsWith("\\") || byteFileName.StartsWith("/")) { byteFileName = byteFileName.Substring(1); } byteFileName = byteFileName.Replace(".lua", ".bytes").Replace("\\", "_").Replace("/", "_"); exportNames.Add("Assets/tmp/" + byteFileName); //File.Copy(file, Path.Combine(tmpPath, byteFileName), true); string srcFile = file.Replace(Path.GetFullPath(Application.dataPath), ""); srcFile = "Assets" + srcFile; Debug.Log(srcFile); sourceFiles.Add(srcFile); } //打包config string cfgPath = Path.GetFullPath(Path.Combine(Application.dataPath, "Config/config")); Debug.Log("Export Lua Path:" + cfgPath); List <string> cfgFiles = getAllChildFiles(cfgPath, "lua"); foreach (string filePath in cfgFiles) { string file = Path.GetFullPath(filePath); if (!file.EndsWith(".lua")) { continue; } string byteFileName = file.Replace(cfgPath, ""); if (byteFileName.StartsWith("\\") || byteFileName.StartsWith("/")) { byteFileName = byteFileName.Substring(1); } byteFileName = byteFileName.Replace(".lua", ".bytes").Replace("\\", "_").Replace("/", "_"); byteFileName = "config_" + byteFileName; exportNames.Add("Assets/tmp/" + byteFileName); //File.Copy(file, Path.Combine(tmpPath, byteFileName), true); string srcFile = file.Replace(Path.GetFullPath(Application.dataPath), ""); srcFile = "Assets" + srcFile; sourceFiles.Add(srcFile); } System.Threading.Thread.Sleep(1000); AssetDatabase.Refresh(); JITBUILDTYPE jbt = GetLuaJitBuildType(EditorUserBuildSettings.activeBuildTarget); SLua.LuajitGen.compileLuaJit(sourceFiles.ToArray(), exportNames.ToArray(), jbt); System.Threading.Thread.Sleep(1000); AssetDatabase.Refresh(); ExportAssetBundle.BuildAssetBundles(exportNames.ToArray(), "Assets/tmp", "luaout.bytes", optionsDefault); string strOutputPath = Path.Combine(Application.streamingAssetsPath, PathUtil.Platform); CheckDirectory(strOutputPath); string luaoutPath = Path.Combine(Application.dataPath, "tmp/luaout.bytes"); string luaExportPath = Path.GetFullPath(Path.Combine(strOutputPath, "lua.u3d")); byte[] by = File.ReadAllBytes(luaoutPath); byte[] encrypt = CryptographHelper.Encrypt(by, KeyVData.Instance.KEY, KeyVData.Instance.IV); File.WriteAllBytes(luaExportPath, encrypt); DirectoryDelete(tmpPath); Debug.Log(luaExportPath + " export."); System.Threading.Thread.Sleep(100); AssetDatabase.Refresh(); }