// 打指定的 extend包 ----By ChenGY using System; using System.Collections.Generic; using System.Linq; using System.Text; using UnityEditor; using System.IO; using UnityEngine; using System.Collections; using MiniJSON; using System.Diagnostics; using taurus.client; using taurus.unity; class BuildBaseWindow: EditorWindow { static public ArrayList gameLit; static public bool all_selected = false; static public bool obl_all_selected = false; static public bool show_version = true; static public bool build32Lua = false; private string initVer = "1.0.0"; static string[] common_string = { "base_script", "common", "lobby", "newgroup", "main_majiang", "main_poker", "main_zipai" }; static TaurusClient web_client; [MenuItem("BuildTools/pack selected base assets %_q")] static public void Init() { UnityEngine.Debug.LogError(Application.persistentDataPath); gameLit = GetList(); NetManager.TIMEOUT_TIME = 100; BuildBaseWindow window = (BuildBaseWindow)EditorWindow.GetWindow(typeof(BuildBaseWindow), false, "Base打包", true); window.ShowAuxWindow(); if (web_client == null || !web_client.isConnected()) web_client = new TaurusClient("http://192.168.0.3:8080/", "web", ConnectionProtocol.Web); else { } } void Update() { NetManager.processEvents(); } protected void OnGUI() { if (gameLit == null) return; GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Label("选择需要的Base进行打包:", GUILayout.Width(150f)); show_version = GUILayout.Toggle(show_version, "显示版本"); build32Lua = GUILayout.Toggle(build32Lua, "是否打包32位lua"); GUILayout.EndHorizontal(); GUILayout.BeginVertical(); GUILayout.Label("请输入版本号:"); initVer = GUILayout.TextField(initVer, GUILayout.Width(200f)); var all_tem = GUILayout.Toggle(all_selected, "全选"); if (all_tem != obl_all_selected) { all_selected = all_tem; } for (int i = 0; i < gameLit.Count; i++) { GUILayout.BeginHorizontal(); GUILayout.Space(20f); var tem = (Hashtable)gameLit[i]; if (all_tem != obl_all_selected) { tem["is_pack"] = all_tem; } else if(!tem.ContainsKey("is_pack")) { tem["is_pack"] = false; } string toggle_name = tem["name"].ToString(); List common_list = new List(common_string); bool is_common = common_list.Contains(toggle_name); if (is_common) { GUI.backgroundColor = Color.Lerp(Color.green, Color.yellow, 0.5f); GUI.contentColor = Color.Lerp(Color.green, Color.yellow, 0.5f); } if (show_version) toggle_name = toggle_name + " [" + tem["ver"].ToString() + "]"; tem["is_pack"] = GUILayout.Toggle((bool)tem["is_pack"], toggle_name); if (is_common) { GUI.backgroundColor = Color.white; GUI.contentColor = Color.white; } GUILayout.EndHorizontal(); } obl_all_selected = all_selected; GUILayout.Space(30f); GUILayout.BeginHorizontal(); GUILayout.Space(20f); if (GUILayout.Button("打包", GUILayout.Width(100f))) { if (EditorUtility.DisplayDialog("提示", "确定打包吗?", "确定", "取消")) { string str_log = ""; ITArray arr = TArray.newInstance(); for (int i = 0; i < gameLit.Count; i++) { var tem = (Hashtable)gameLit[i]; if ((bool)tem["is_pack"]) { //str_log += "," + tem["name"].ToString(); arr.addString(tem["name"].ToString()); } } var arr_ver = app_ver.Split('.'); var new_ver = string.Format("{0}.{1}.{2}", arr_ver[0], arr_ver[1], ((Convert.ToInt32(arr_ver[2])) + 1).ToString()); str_log = string.Format("客户端 测试服:\rbase({0})", new_ver); UnityEngine.Debug.LogError(str_log); if (arr.size() > 0) { //str_log = str_log.Substring(1); TextEditor t = new TextEditor(); t.content = new GUIContent(str_log); t.OnFocus(); t.Copy(); ITObject param = TObject.newInstance(); param.putString("ver", app_ver); param.putTArray("list", arr); // EditorUtility.DisplayProgressBar("正在生成", "服务器正在打包请稍后。。。", 0.2f); //EditorUtility.DisplayProgressBar("正在生成", "服务器正在打包请稍后。。。", 0.2f); //NetManager.debug_print = true; //web_client.send("pack/pack_base", param, (res) => { // EditorUtility.ClearProgressBar(); // web_client.killConnection(); // Close(); //}); } PackUtil.Base_Pack_Custom(EditorUserBuildSettings.activeBuildTarget,gameLit); } } GUILayout.Space(20f); if (GUILayout.Button("取消", GUILayout.Width(100f))) { this.Close(); } GUILayout.Space(20f); GUILayout.EndHorizontal(); } static string app_ver = "1.0.0"; static ArrayList GetList() { // app_ver = GetVersion("File://" + Application.streamingAssetsPath + "/init1_1.json"); string tt = Application.streamingAssetsPath + "/" + "init2_1.json"; UnityEngine.Debug.Log(tt); var tem = new WWW(tt);// new WWW("http://47.112.97.12:8077/Config/init1_2.json"); while (!tem.isDone) { System.Threading.Thread.Sleep(10); } if (!string.IsNullOrEmpty(tem.error)) { return null; } var config_list = (ArrayList)MiniJSON.Json.Deserialize(tem.text); UnityEngine.Debug.Log(tem.text); // UnityEngine.Debug.LogError("打包配置数据==>>>" + tem.text); return config_list; } static string GetVersion(string init_url) { var request = new WWW(init_url); while (!request.isDone) { System.Threading.Thread.Sleep(10); } if (!string.IsNullOrEmpty(request.error)) { return null; } var json_data = request.text; var json = Json.Deserialize(json_data) as Hashtable; var pack_url = (string)json["pack_url"]; var tem_p = (Hashtable)json[ResourcesManager.OS_Dir]; var version = (string)tem_p["version"]; return version; } }