public static void Build(bool encrypt = false) { //每次打包前一定要调用一次这个方法,这个方法会对配置过的代码做预处理,之后才能加载补丁代码 IFixEditor.InjectAssemblys(); //addressable打包和assetBundle打包,调用不同的接口 if (FrameConstr.UseAssetAddress == AssetAddress.Addressable) { AddressableAssetSettings.BuildPlayerContent(); } else { //打ab包 if (encrypt) { BundleEditor.EncryptionBuild(); } else { BundleEditor.NormalBuild(); } } //写入版本号 SaveVersion(PlayerSettings.bundleVersion, PlayerSettings.applicationIdentifier, encrypt); //生成可执行程序 string savePath = ""; if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android) { //PlayerSettings.Android.keystorePass = "******"; //PlayerSettings.Android.keyaliasPass = "******"; //PlayerSettings.Android.keyaliasName = "android.keystore"; //PlayerSettings.Android.keystoreName = Application.dataPath.Replace("/Assets", "") + "/improve.keystore"; savePath = m_AndroidPath + m_AppName + "_" + EditorUserBuildSettings.activeBuildTarget + string.Format("_{0:yyyy_MM_dd_HH_mm}", DateTime.Now) + ".apk"; } else if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.iOS) { savePath = m_IOSPath + m_AppName + "_" + EditorUserBuildSettings.activeBuildTarget + string.Format("_{0:yyyy_MM_dd_HH_mm}", DateTime.Now); } else if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows || EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows64) { savePath = m_WindowsPath + m_AppName + "_" + EditorUserBuildSettings.activeBuildTarget + string.Format("_{0:yyyy_MM_dd_HH_mm}/{1}.exe", DateTime.Now, m_AppName); } BuildPipeline.BuildPlayer(FindEnableEditorrScenes(), savePath, EditorUserBuildSettings.activeBuildTarget, BuildOptions.None); if (FrameConstr.UseAssetAddress != AssetAddress.Addressable) { //删除 DeleteDir(Application.streamingAssetsPath); } }
public static void BuildIOS() { //打ab包 BundleEditor.NormalBuild(); BuildSetting buildSetting = GetIOSBuildSetting(); string suffix = SetIOSSetting(buildSetting); //清空生成的文件夹 DeleteDir(m_IOSPath); string name = m_AppName + "_IOS" + suffix + string.Format("_{0:yyyy_MM_dd_HH_mm}", DateTime.Now); string savePath = m_IOSPath + name; //生成可执行程序 BuildPipeline.BuildPlayer(FindEnableEditorrScenes(), savePath, EditorUserBuildSettings.activeBuildTarget, BuildOptions.None); DeleteDir(Application.streamingAssetsPath); WriteBuildName(name); }
private void OnGUI() { GUILayout.BeginHorizontal(); md5Path = EditorGUILayout.TextField("ABMD5路径: ", md5Path, GUILayout.Width(350), GUILayout.Height(20)); if (GUILayout.Button("选择版本ABMD5文件", GUILayout.Width(150), GUILayout.Height(30))) { m_OpenFileName = new OpenFileName(); m_OpenFileName.structSize = Marshal.SizeOf(m_OpenFileName); m_OpenFileName.filter = "ABMD5文件(*.bytes)\0*.bytes"; m_OpenFileName.file = new string(new char[256]); m_OpenFileName.maxFile = m_OpenFileName.file.Length; m_OpenFileName.fileTitle = new string(new char[64]); m_OpenFileName.maxFileTitle = m_OpenFileName.fileTitle.Length; m_OpenFileName.initialDir = (Application.dataPath + "/../Version").Replace("/", "\\");//默认路径 m_OpenFileName.title = "选择MD5窗口"; m_OpenFileName.flags = 0x00080000 | 0x00001000 | 0x00000800 | 0x00000008; if (LocalDialog.GetSaveFileName(m_OpenFileName)) { Debug.Log(m_OpenFileName.file); md5Path = m_OpenFileName.file; } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); hotCount = EditorGUILayout.TextField("热更补丁版本:", hotCount, GUILayout.Width(350), GUILayout.Height(20)); GUILayout.EndHorizontal(); if (GUILayout.Button("开始打热更包", GUILayout.Width(100), GUILayout.Height(50))) { if (!string.IsNullOrEmpty(md5Path) && md5Path.EndsWith(".bytes")) { BundleEditor.Build(false, true, md5Path, hotCount); } } GUILayout.BeginHorizontal(); if (GUILayout.Button("开始打加密热更包", GUILayout.Width(100), GUILayout.Height(50))) { if (!string.IsNullOrEmpty(md5Path) && md5Path.EndsWith(".bytes")) { BundleEditor.Build(true, true, md5Path, hotCount); } } GUILayout.EndHorizontal(); }
public static void BuildAndroid() { //打ab包 BundleEditor.NormalBuild(); PlayerSettings.Android.keystorePass = "******"; PlayerSettings.Android.keyaliasPass = "******"; PlayerSettings.Android.keyaliasName = "android.keystore"; PlayerSettings.Android.keystoreName = Application.dataPath.Replace("/Assets", "") + "/realfram.keystore"; BuildSetting buildSetting = GetAndoridBuildSetting(); string suffix = SetAndroidSetting(buildSetting); //清空生成的文件夹 DeleteDir(m_AndroidPath); string savePath = m_AndroidPath + m_AppName + "_Andorid" + suffix + string.Format("_{0:yyyy_MM_dd_HH_mm}.apk", DateTime.Now); //生成可执行程序 BuildPipeline.BuildPlayer(FindEnableEditorrScenes(), savePath, EditorUserBuildSettings.activeBuildTarget, BuildOptions.None); DeleteDir(Application.streamingAssetsPath); }