public static void Build() { //打AssetBundle BundleEditor.BuildAB(); //写入版本数据 SaveVersion(PlayerSettings.bundleVersion, PlayerSettings.applicationIdentifier); //打包后的AssetBundle的路径 string sourcePath = BundleEditor.m_BuildABPath + "/"; string targetPath = Application.streamingAssetsPath + "/"; //将初始资源转到到StreamAsset路径下 Copy(sourcePath, targetPath); string savePath = ""; if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android) { savePath = m_AndroidPath + m_AppName + "_" + EditorUserBuildSettings.activeBuildTarget.ToString() + string.Format("_{0:yyyy_MM_dd_HH_mm}", DateTime.Now) + ".apk"; } else if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.iOS) { savePath = m_iOSPath + m_AppName + "_" + EditorUserBuildSettings.activeBuildTarget.ToString() + string.Format("_{0:yyyy_MM_dd_HH_mm}", DateTime.Now); } else if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows64 || EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows) { savePath = m_WindowsPath + m_AppName + "_" + EditorUserBuildSettings.activeBuildTarget + string.Format("_{0:yyyy_MM_dd_HH_mm}/{1}.exe", DateTime.Now, m_AppName); } BuildPipeline.BuildPlayer(FindEnableLevel(), savePath, EditorUserBuildSettings.activeBuildTarget, BuildOptions.None); //打包之后删除 DeleteStreamAssets(); AssetDatabase.Refresh(); }
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(20))) { 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("ABMD5文件路径", hotCount, GUILayout.Width(350), GUILayout.Height(20)); GUILayout.EndHorizontal(); if (GUILayout.Button("开始打热更包", GUILayout.Width(100), GUILayout.Height(20))) { if (!string.IsNullOrEmpty(md5Path) && md5Path.EndsWith("bytes")) { BundleEditor.BuildAB(true, md5Path, hotCount); } } }