public void updateState(string name) { if (selectedServer == null) { return; } if (mList == null) { return; } Hashtable item = null; for (int i = 0; i < mList.Count; i++) { item = ListEx.getMap(mList, i); if (name.Equals(MapEx.getString(item, "name"))) { // item ["upload"] = true; Hashtable m = MapEx.getMap(item, "upload"); m = m == null ? new Hashtable() : m; m [selectedServer.key] = true; item ["upload"] = m; break; } } string str = JSON.JsonEncode(mList); File.WriteAllText(Application.dataPath + "/" + cfgPath, str); }
public override void Deserialize(Hashtable map) { #if UNITY_EDITOR base.Deserialize(map); begainIndex = MapEx.getInt(map, "begainIndex"); maxIndex = MapEx.getInt(map, "maxIndex"); string actionClass = MapEx.getString(map, "actionClass"); if (string.IsNullOrEmpty(actionClass)) { monoScript = null; } else { monoScript = AssetDatabase.LoadAssetAtPath(actionClass, typeof(MonoScript)) as MonoScript; if (monoScript != null) { Type tp = monoScript.GetClass(); attr = Activator.CreateInstance(tp) as ActionBase; if (attr != null) { attr.Deserialize(MapEx.getMap(map, "attr")); } } } #endif }
public override void Deserialize(Hashtable map) { triggerType = MapEx.getInt(map, "triggerType"); hideSelf = MapEx.getBool(map, "hideSelf"); talkId = MapEx.getInt(map, "talkId"); npcCfg = MapEx.getString(map, "npcCfg"); boxCfg = MapEx.getString(map, "boxCfg"); }
public static WorldmapEditorCfg parse(Hashtable map) { WorldmapEditorCfg cfg = new WorldmapEditorCfg(); cfg.size = MapEx.getInt(map, "size"); cfg.pageSize = MapEx.getInt(map, "pageSize"); cfg.mapAreaTexturePath = MapEx.getString(map, "mapAreaTexturePath"); cfg.colors4MapAreaJson = MapEx.getString(map, "colors4MapAreaJson"); return(cfg); }
public virtual void Deserialize(Hashtable map) { float x = float.Parse(map ["editorx"].ToString()); float y = float.Parse(map ["editory"].ToString()); editorPosition = new Vector2(x, y); id = MapEx.getInt(map, "id"); desc = MapEx.getString(map, "desc"); index = MapEx.getInt(map, "index"); canMultTimes = MapEx.getBool(map, "canMultTimes"); }
public void onGetUpgradePkgMultMode(params object[] paras) { Hashtable d = paras [0] as Hashtable; string platform = paras [1] as string; string oldMd5 = ""; // if (EditorUtility.DisplayDialog("Alert", "Really want to upgrade all selected servers!!", "Okay", "Cancel")) { foreach (DictionaryEntry cell in servers) { Hashtable server = cell.Value as Hashtable; if (MapEx.getBool(server, "selected")) { string verKey = ""; string vetType = "1"; if (platform.Equals("ios")) { verKey = "iosversion"; vetType = "1"; } else if (platform.Equals("Android")) { verKey = "androidversion"; vetType = "2"; } else if (platform.Equals("win")) { verKey = "winversion"; vetType = "3"; } else if (platform.Equals("osx")) { verKey = "osxversion"; vetType = "4"; } oldMd5 = MapEx.getString(server, verKey); string newMd5 = MapEx.getString(d, "md5"); if (!newMd5.Equals(oldMd5)) { server [verKey] = newMd5; server ["pkgName"] = MapEx.getString(d, "name"); server ["pkgRemark"] = MapEx.getString(d, "remark"); saveData(MapEx.getString(server, "idx"), newMd5, vetType); } } } } }
public void onGetUpgradePkg(params object[] paras) { string oldMd5 = ""; Hashtable d = paras [0] as Hashtable; ArrayList orgsList = paras [1] as ArrayList; string key = orgsList [0] as string; string platform = orgsList [1] as string; Hashtable server = MapEx.getMap(servers, key); string verKey = ""; string vetType = "1"; if (platform.Equals("ios")) { verKey = "iosversion"; vetType = "1"; } else if (platform.Equals("Android")) { verKey = "androidversion"; vetType = "2"; } else if (platform.Equals("win")) { verKey = "winversion"; vetType = "3"; } else if (platform.Equals("osx")) { verKey = "osxversion"; vetType = "4"; } oldMd5 = MapEx.getString(server, verKey); string newMd5 = MapEx.getString(d, "md5"); if (!newMd5.Equals(oldMd5)) { if (EditorUtility.DisplayDialog("Alert", "Really want to upgrade this server!!", "Okay", "Cancel")) { server [verKey] = newMd5; server ["pkgName"] = MapEx.getString(d, "name"); server ["pkgRemark"] = MapEx.getString(d, "remark"); servers [key] = server; saveData(MapEx.getString(server, "idx"), newMd5, vetType); } } }
public void refreshData() { servers = null; getUpgradePkgListData(); if (selectedServer == null) { return; } // string __httpBaseUrl = PStr.b ().a ("http://").a (Net.self.gateHost).a (":").a (Net.self.gatePort).e (); // string url = PStr.b ().a (__httpBaseUrl).a ("/KokDirServer/ServerServlet").e (); string url = selectedServer.getServerListUrl; if (string.IsNullOrEmpty(url)) { return; } Dictionary <string, object> paras = new Dictionary <string, object> (); paras ["serverType"] = 1; HttpWebResponse response = HttpEx.CreatePostHttpResponse(url, paras, 10000, System.Text.Encoding.UTF8); if (response == null) { return; } string str = HttpEx.readString(response); response.Close(); // Debug.Log (url); // string str = HttpEx.readString (url, null); Debug.Log(str); servers = JSON.DecodeMap(str); Hashtable server = null; Hashtable pkg = null; if (servers != null) { foreach (DictionaryEntry cell in servers) { server = cell.Value as Hashtable; pkg = getUpgradePkgByMd5(MapEx.getString(server, "version")); server ["pkgName"] = MapEx.getString(pkg, "name"); server ["pkgRemark"] = MapEx.getString(pkg, "remark"); } } }
Hashtable getUpgradePkgByMd5(string md5) { if (upgradePkgList == null) { getUpgradePkgListData(); } Hashtable cell = null; for (int i = 0; i < upgradePkgList.Count; i++) { cell = (Hashtable)(upgradePkgList [i]); if (MapEx.getString(cell, "md5") == md5) { return(cell); } } return(null); }
public void refreshData() { if (mList == null) { return; } Hashtable item = null; for (int i = 0; i < mList.Count; i++) { item = ListEx.getMap(mList, i); if (Directory.Exists(getUpgradePackagePath(MapEx.getString(item, "name")))) { item ["exist"] = true; } else { item ["exist"] = false; } } }
void applyPackTexture(int maxSize, bool unityPacking) { string texturePath = EditorUtility.OpenFolderPanel("Save packed texture", Application.dataPath + "/" + CLPathCfg.self.basePath + "/upgradeRes4Dev/other", ""); if (string.IsNullOrEmpty(texturePath)) { return; } if (packTex == null || packRects == null || packRects.Length == 0 || packSprites == null || packSprites.Count == 0 || packRects.Length != packSprites.Count) { packTextures(maxSize, isUseUnityPacking); } string packTextureFile = Path.Combine(texturePath, packedName + ".png"); string packTextureFile4Atlas = packTextureFile.Replace(Application.dataPath + "/", ""); Debug.LogWarning(packTextureFile4Atlas); byte[] bytes = packTex.EncodeToPNG(); Directory.CreateDirectory(Path.GetDirectoryName(packTextureFile)); File.WriteAllBytes(packTextureFile, bytes); AssetDatabase.ImportAsset("Assets/" + packTextureFile4Atlas); TextureImporter textureImporter = AssetImporter.GetAtPath("Assets/" + packTextureFile4Atlas) as TextureImporter; textureImporter.textureType = TextureImporterType.GUI; textureImporter.mipmapEnabled = false; textureImporter.wrapMode = TextureWrapMode.Clamp; textureImporter.alphaIsTransparency = true; textureImporter.npotScale = TextureImporterNPOTScale.None; textureImporter.filterMode = FilterMode.Trilinear; //改成这种模式好像更省内存 AssetDatabase.ImportAsset("Assets/" + packTextureFile4Atlas); Hashtable m = null; Hashtable d = null; Hashtable atlasMap = null; UIAtlas atlas = null; UISpriteData spData = null; Rect _rect; for (int i = 0; i < packSprites.Count; i++) { m = packSprites [i] as Hashtable; _rect = packRects [i]; d = MapEx.getMap(m, "data"); atlasMap = MapEx.getMap(m, "atlas"); foreach (DictionaryEntry item in atlasMap) { atlas = getAtlasByName(item.Key.ToString()); if (atlas == null) { Debug.LogError("Get atlas is null!!==" + item.Key); continue; } // spData = atlas.GetSprite (MapEx.getString (d, "name")); string spName = MapEx.getString(d, "name"); if (!atlas.spriteMap.ContainsKey(spName)) { Debug.LogError("atlas.GetSprite is null!!==" + spName); continue; } int index = MapEx.getInt(atlas.spriteMap, spName); spData = atlas.spriteList [index]; if (spData == null) { Debug.LogError("atlas.GetSprite is null!!==" + spName); continue; } string toPath = texturePath + "/" + spData.path.Replace(CLPathCfg.self.basePath + "/upgradeRes4Dev/other/", ""); Directory.CreateDirectory(Path.GetDirectoryName(toPath)); toPath = toPath.Replace(Application.dataPath + "/", ""); AssetDatabase.ImportAsset(Path.GetDirectoryName("Assets/" + toPath)); string err = AssetDatabase.MoveAsset("Assets/" + spData.path, "Assets/" + toPath); if (!string.IsNullOrEmpty(err)) { Debug.LogError(err); } if (removePublishRes) { string fromPath = Path.GetDirectoryName(spData.path) + "/Android/" + Path.GetFileNameWithoutExtension(spData.path) + ".unity3d"; fromPath = fromPath.Replace("/upgradeRes4Dev/", "/upgradeRes4Publish/"); if (File.Exists(Application.dataPath + "/" + fromPath)) { File.Delete(Application.dataPath + "/" + fromPath); } fromPath = Path.GetDirectoryName(spData.path) + "/IOS/" + Path.GetFileNameWithoutExtension(spData.path) + ".unity3d"; fromPath = fromPath.Replace("/upgradeRes4Dev/", "/upgradeRes4Publish/"); if (File.Exists(Application.dataPath + "/" + fromPath)) { File.Delete(Application.dataPath + "/" + fromPath); } } spData.path = packTextureFile4Atlas; spData.x = Mathf.RoundToInt(_rect.x); spData.y = Mathf.RoundToInt(_rect.y); EditorUtility.SetDirty(atlas.gameObject); AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(atlas.gameObject)); } } AssetDatabase.SaveAssets(); AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport); EditorUtility.DisplayDialog("success", "Finished!", "Okay"); }
public BehaviorTree Deserialize() { Hashtable map = JSON.DecodeMap(serializedBehaviorTree); // Behavior Tree BehaviorTree bt = ScriptableObject.CreateInstance <BehaviorTree> (); ArrayList nodes = MapEx.getList(map, "nodes"); string type = ""; Node node = null; //先把所有的node创建好 for (int i = 0; i < nodes.Count; i++) { type = MapEx.getString(nodes [i], "type"); switch (type) { case "Hivemind.Root": node = bt.CreateNode <Root> (); ((Root)node).Deserialize(ListEx.getMap(nodes, i)); bt.SetRoot((Root)node); break; case "Hivemind.NodeAction": node = bt.CreateNode <NodeAction> (); node.Deserialize(ListEx.getMap(nodes, i)); bt.nodes.Add(node); break; case "Hivemind.NodeBranch": node = bt.CreateNode <NodeBranch> (); node.Deserialize(ListEx.getMap(nodes, i)); bt.nodes.Add(node); break; case "Hivemind.NodeTogether": node = bt.CreateNode <NodeTogether> (); node.Deserialize(ListEx.getMap(nodes, i)); bt.nodes.Add(node); break; default: node = bt.CreateNode <Node> (); node.Deserialize(ListEx.getMap(nodes, i)); bt.nodes.Add(node); break; } } // 处理子节点的的关系 for (int i = 0; i < nodes.Count; i++) { node = bt.getNodeByID(MapEx.getInt(nodes [i], "id")); node.DeserializeChildren(ListEx.getMap(nodes, i)); } behaviorTree = bt; return(bt); //============================= // XmlDocument doc = new XmlDocument(); // doc.LoadXml(serializedBehaviorTree); // Behavior Tree // BehaviorTree bt = ScriptableObject.CreateInstance<BehaviorTree>(); // Root // XmlElement rootEl = (XmlElement)doc.GetElementsByTagName ("root").Item (0); // Root root = (Root)DeserializeSubTree (rootEl, bt); // bt.SetRoot (root); // // // Unparented nodes // XmlElement unparentedRoot = (XmlElement)doc.GetElementsByTagName ("unparented").Item (0); // foreach (XmlNode xmlNode in unparentedRoot.ChildNodes) { // XmlElement el = xmlNode as XmlElement; // if (el != null) // DeserializeSubTree (el, bt); // } // // behaviorTree = bt; // return bt; }
void OnGUI() { if (!ECLProjectSetting.isProjectExit(ECLProjectManager.self)) { GUIStyle style = new GUIStyle(); style.fontSize = 20; style.normal.textColor = Color.yellow; GUILayout.Label("The scene is not ready, create it now?", style); if (GUILayout.Button("Show Project Manager")) { EditorWindow.GetWindow <ECLProjectManager> (false, "CoolapeProject", true); } Close(); return; } if (ECLProjectManager.data.hotUpgradeServers.Count > 0) { ECLEditorUtl.BeginContents(); { List <string> toolbarNames = new List <string> (); for (int i = 0; i < ECLProjectManager.data.hotUpgradeServers.Count; i++) { HotUpgradeServerInfor dd = ECLProjectManager.data.hotUpgradeServers [i] as HotUpgradeServerInfor; toolbarNames.Add(dd.name); } selectedServerIndex = GUILayout.Toolbar(selectedServerIndex, toolbarNames.ToArray()); HotUpgradeServerInfor hsi = ECLProjectManager.data.hotUpgradeServers [selectedServerIndex] as HotUpgradeServerInfor; selectedServer = hsi; // ECLProjectSetting.cellServerInor (hsi, false); //=================================================== GUILayout.BeginHorizontal(); { GUILayout.Label("Key:", ECLEditorUtl.width200); GUILayout.TextField(selectedServer.key); } GUILayout.EndHorizontal(); //=================================================== GUILayout.BeginHorizontal(); { GUILayout.Label("Hot Upgrade Base Url:", ECLEditorUtl.width200); GUILayout.TextField(selectedServer.hotUpgradeBaseUrl); } GUILayout.EndHorizontal(); //=================================================== GUILayout.BeginHorizontal(); { GUILayout.Label("Host 4 Upload Upgrade Package:", ECLEditorUtl.width200); GUILayout.TextField(selectedServer.host4UploadUpgradePackage); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Port 4 Upload Upgrade Package:", ECLEditorUtl.width200); EditorGUILayout.IntField(selectedServer.port4UploadUpgradePackage); } GUILayout.EndHorizontal(); } ECLEditorUtl.EndContents(); } if (selectedServer == null) { GUILayout.Label("Please select a server!"); return; } EditorGUILayout.BeginHorizontal(); { GUI.color = Color.green; if (GUILayout.Button("Refresh", GUILayout.Height(40f))) { setData(); } GUI.color = Color.white; if (!isSelectMod) { if (GUILayout.Button("Save", GUILayout.Height(40f))) { if (mList == null || mList.Count == 0) { Debug.LogWarning("Nothing need to save!"); return; } string str = JSON.JsonEncode(mList); File.WriteAllText(Application.dataPath + "/" + cfgPath, str); } } } EditorGUILayout.EndHorizontal(); ECLEditorUtl.BeginContents(); { EditorGUILayout.BeginHorizontal(); { EditorGUILayout.LabelField("Package Name", GUILayout.Width(160)); EditorGUILayout.LabelField("MD5", GUILayout.Width(250)); EditorGUILayout.LabelField("Exist?", GUILayout.Width(40)); EditorGUILayout.LabelField("Upload?", GUILayout.Width(60)); EditorGUILayout.LabelField("...", GUILayout.Width(60)); EditorGUILayout.LabelField("Notes"); } EditorGUILayout.EndHorizontal(); if (mList == null) { return; } scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(position.width), GUILayout.Height(position.height - 75)); { for (int i = mList.Count - 1; i >= 0; i--) { item = ListEx.getMap(mList, i); EditorGUILayout.BeginHorizontal(); { EditorGUILayout.TextField(MapEx.getString(item, "name"), GUILayout.Width(160)); EditorGUILayout.TextField(MapEx.getString(item, "md5"), GUILayout.Width(250)); if (!MapEx.getBool(item, "exist")) { GUI.color = Color.red; } EditorGUILayout.TextField(MapEx.getBool(item, "exist") ? "Yes" : "No", GUILayout.Width(40)); GUI.color = Color.white; if (!isUploaded(item)) { GUI.color = Color.red; } EditorGUILayout.TextField(isUploaded(item) ? "Yes" : "No", GUILayout.Width(60)); GUI.color = Color.white; if (MapEx.getBool(item, "exist")) { GUI.enabled = true; } else { GUI.enabled = false; } GUI.color = Color.yellow; if (isSelectMod) { if (GUILayout.Button("select", GUILayout.Width(60f))) { Close(); Utl.doCallback(onSelectedCallback, item, selectedCallbackParams); } } else { if (GUILayout.Button("upload", GUILayout.Width(60f))) { if (EditorUtility.DisplayDialog("Alert", "Really want to upload the upgrade package?", "Okey", "cancel")) { selectedPackageName = MapEx.getString(item, "name"); uploadUpgradePackage(MapEx.getString(item, "name")); } } if (GUILayout.Button("同步OSS", GUILayout.Width(60f))) { if (EditorUtility.DisplayDialog("Alert", "Really want to upload the upgrade package?", "Okey", "cancel")) { uploadOss(MapEx.getString(item, "name")); } } } GUI.color = Color.white; GUI.enabled = true; item ["remark"] = EditorGUILayout.TextArea(MapEx.getString(item, "remark")); GUILayout.Space(5); } EditorGUILayout.EndHorizontal(); } } EditorGUILayout.EndScrollView(); } ECLEditorUtl.EndContents(); }
void OnGUI() { if (!ECLProjectSetting.isProjectExit(ECLProjectManager.self)) { GUIStyle style = new GUIStyle(); style.fontSize = 20; style.normal.textColor = Color.yellow; GUILayout.Label("The scene is not ready, create it now?", style); if (GUILayout.Button("Show Project Manager")) { EditorWindow.GetWindow <ECLProjectManager> (false, "CoolapeProject", true); } Close(); return; } if (ECLProjectManager.data.hotUpgradeServers.Count <= 0) { GUI.color = Color.red; GUILayout.Label("There is no server"); GUI.color = Color.white; return; } if (ECLProjectManager.data.hotUpgradeServers.Count > 0) { ECLEditorUtl.BeginContents(); { List <string> toolbarNames = new List <string> (); for (int i = 0; i < ECLProjectManager.data.hotUpgradeServers.Count; i++) { HotUpgradeServerInfor dd = ECLProjectManager.data.hotUpgradeServers [i] as HotUpgradeServerInfor; toolbarNames.Add(dd.name); } int index = GUILayout.Toolbar(selectedServerIndex, toolbarNames.ToArray()); HotUpgradeServerInfor hsi = ECLProjectManager.data.hotUpgradeServers [index] as HotUpgradeServerInfor; selectedServer = hsi; if (selectedServerIndex != index) { selectedServerIndex = index; refreshData(); } //=================================================== GUILayout.BeginHorizontal(); { GUILayout.Label("Key:", ECLEditorUtl.width200); GUILayout.TextField(selectedServer.key); } GUILayout.EndHorizontal(); //=================================================== GUILayout.BeginHorizontal(); { GUILayout.Label("URL of get server list:", ECLEditorUtl.width200); GUILayout.TextField(selectedServer.getServerListUrl); } GUILayout.EndHorizontal(); //=================================================== GUILayout.BeginHorizontal(); { GUILayout.Label("URL of set upgrade pkg md5:", ECLEditorUtl.width200); GUILayout.TextField(selectedServer.setServerPkgMd5Url); } GUILayout.EndHorizontal(); } ECLEditorUtl.EndContents(); } GUI.color = Color.green; if (GUILayout.Button("Refresh")) { refreshData(); } GUI.color = Color.white; if (servers == null || servers.Count == 0) { return; } GUILayout.Space(5); EditorGUILayout.BeginHorizontal(); { if (GUILayout.Button("All", GUILayout.Width(30))) { isSelectAll = !isSelectAll; foreach (DictionaryEntry cell in servers) { server = (Hashtable)(cell.Value); server ["selected"] = isSelectAll; } } EditorGUILayout.LabelField("SID", GUILayout.Width(80)); EditorGUILayout.LabelField("SName", GUILayout.Width(100)); GUI.color = Color.yellow; #if UNITY_ANDROID EditorGUILayout.LabelField("UpgradeMd5Ver(Android)", GUILayout.Width(250)); #elif UNITY_IPHONE || UNITY_IOS EditorGUILayout.LabelField("UpgradeMd5Ver(ios)", GUILayout.Width(250)); #elif UNITY_STANDALONE_WIN EditorGUILayout.LabelField("UpgradeMd5Ver(win)", GUILayout.Width(250)); #elif UNITY_STANDALONE_OSX EditorGUILayout.LabelField("UpgradeMd5Ver(osx)", GUILayout.Width(250)); #elif UNITY_WEBGL EditorGUILayout.LabelField("UpgradeMd5Ver(webgl)", GUILayout.Width(250)); #endif EditorGUILayout.LabelField("UpgradePkg Name", GUILayout.Width(160)); EditorGUILayout.LabelField("UpgradePkg Mark", GUILayout.Width(250)); GUI.color = Color.white; #if UNITY_ANDROID if (GUILayout.Button("Select Md5(Android)")) { setUpgradePkgMutlMode("Android"); } #elif UNITY_IPHONE || UNITY_IOS if (GUILayout.Button("Select Md5(ios)")) { setUpgradePkgMutlMode("ios"); } #elif UNITY_STANDALONE_WIN if (GUILayout.Button("Select Md5(win)")) { setUpgradePkgMutlMode("win"); } #elif UNITY_STANDALONE_OSX if (GUILayout.Button("Select Md5(osx)")) { setUpgradePkgMutlMode("osx"); } #elif UNITY_WEBGL if (GUILayout.Button("Select Md5(webgl)")) { setUpgradePkgMutlMode("webgl"); } #endif } EditorGUILayout.EndHorizontal(); GUILayout.Space(5); ECLEditorUtl.BeginContents(); { scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(position.width), GUILayout.Height(position.height - 50)); { foreach (DictionaryEntry cell in servers) { server = (Hashtable)(cell.Value); EditorGUILayout.BeginHorizontal(); { server ["selected"] = EditorGUILayout.Toggle(MapEx.getBool(server, "selected"), GUILayout.Width(30)); if (MapEx.getBool(server, "selected")) { GUI.color = Color.cyan; } else { GUI.color = Color.white; } EditorGUILayout.TextField(MapEx.getString(server, "idx"), GUILayout.Width(80)); EditorGUILayout.TextField(MapEx.getString(server, "servername"), GUILayout.Width(100)); GUI.color = Color.yellow; #if UNITY_ANDROID EditorGUILayout.TextField(MapEx.getString(server, "androidversion"), GUILayout.Width(250)); #elif UNITY_IPHONE || UNITY_IOS EditorGUILayout.TextField(MapEx.getString(server, "iosversion"), GUILayout.Width(250)); #elif UNITY_STANDALONE_WIN EditorGUILayout.TextField(MapEx.getString(server, "winversion"), GUILayout.Width(250)); #elif UNITY_STANDALONE_OSX EditorGUILayout.TextField(MapEx.getString(server, "osxversion"), GUILayout.Width(250)); #elif UNITY_WEBGL EditorGUILayout.TextField(MapEx.getString(server, "webglversion"), GUILayout.Width(250)); #endif EditorGUILayout.TextField(MapEx.getString(server, "pkgName"), GUILayout.Width(160)); EditorGUILayout.TextArea(MapEx.getString(server, "pkgRemark"), GUILayout.Width(250)); GUI.color = Color.white; #if UNITY_ANDROID if (GUILayout.Button("Select Md5(Android)")) { ECLUpgradeListProc.popup4Select((Callback)onGetUpgradePkg, ListEx.builder().Add(cell.Key).Add("Android").ToList()); } #elif UNITY_IPHONE || UNITY_IOS if (GUILayout.Button("Select Md5(ios)")) { ECLUpgradeListProc.popup4Select((Callback)onGetUpgradePkg, ListEx.builder().Add(cell.Key).Add("ios").ToList()); } #elif UNITY_STANDALONE_WIN if (GUILayout.Button("Select Md5(win)")) { ECLUpgradeListProc.popup4Select((Callback)onGetUpgradePkg, ListEx.builder().Add(cell.Key).Add("win").ToList()); } #elif UNITY_STANDALONE_OSX if (GUILayout.Button("Select Md5(osx)")) { ECLUpgradeListProc.popup4Select((Callback)onGetUpgradePkg, ListEx.builder().Add(cell.Key).Add("osx").ToList()); } #elif UNITY_WEBGL if (GUILayout.Button("Select Md5(webgl)")) { ECLUpgradeListProc.popup4Select((Callback)onGetUpgradePkg, ListEx.builder().Add(cell.Key).Add("wegbl").ToList()); } #endif } EditorGUILayout.EndHorizontal(); } } EditorGUILayout.EndScrollView(); } ECLEditorUtl.EndContents(); }
static void doCreate(string path, Hashtable lastOtherVer, Hashtable lastPriorityVer, Hashtable lastCfgdataVer, ref Hashtable outMap) { string[] fileEntries = Directory.GetFiles(path); string extension = ""; string filePath = ""; string md5Str = ""; foreach (string fileName in fileEntries) { extension = Path.GetExtension(fileName); if (ECLEditorUtl.isIgnoreFile(fileName)) { continue; } filePath = filter(fileName); filePath = filePath.Replace("\\", "/"); filePath = filePath.Replace("/upgradeRes4Publish/", "/upgradeRes/"); if (ECLProjectManager.isModified(fileName)) { md5Str = Utl.MD5Encrypt(File.ReadAllBytes(fileName)); } else { md5Str = MapEx.getString(lastOtherVer, filePath); if (string.IsNullOrEmpty(md5Str)) { md5Str = MapEx.getString(lastPriorityVer, filePath); } else if (string.IsNullOrEmpty(md5Str)) { md5Str = MapEx.getString(lastCfgdataVer, filePath); } } outMap [filePath] = md5Str; } string[] dirEntries = Directory.GetDirectories(path); foreach (string dir in dirEntries) { //跳过不同平台的资源 #if UNITY_ANDROID if (Path.GetFileName(dir).Equals("IOS") || Path.GetFileName(dir).Equals("Standalone") || Path.GetFileName(dir).Equals("StandaloneOSX")) { continue; } #elif UNITY_IOS if (Path.GetFileName(dir).Equals("Android") || Path.GetFileName(dir).Equals("Standalone") || Path.GetFileName(dir).Equals("StandaloneOSX")) { continue; } #elif UNITY_STANDALONE_WIN if (Path.GetFileName(dir).Equals("Android") || Path.GetFileName(dir).Equals("IOS") || Path.GetFileName(dir).Equals("StandaloneOSX")) { continue; } #elif UNITY_STANDALONE_OSX if (Path.GetFileName(dir).Equals("Android") || Path.GetFileName(dir).Equals("IOS") || Path.GetFileName(dir).Equals("Standalone")) { continue; } #endif doCreate(dir, lastOtherVer, lastPriorityVer, lastCfgdataVer, ref outMap); } }
void showCellSprite(Hashtable m) { Hashtable d = MapEx.getMap(m, "data"); Texture tex = ECLEditorUtl.getObjectByPath(MapEx.getString(d, "path")) as Texture; if (tex == null) { return; } // NGUIEditorTools.DrawTiledTexture (rect, NGUIEditorTools.backdropTexture); Rect uv = new Rect(MapEx.getInt(d, "x"), MapEx.getInt(d, "y"), MapEx.getInt(d, "width"), MapEx.getInt(d, "height")); uv = NGUIMath.ConvertToTexCoords(uv, tex.width, tex.height); float scaleX = rect.width / uv.width; float scaleY = rect.height / uv.height; // Stretch the sprite so that it will appear proper float aspect = (scaleY / scaleX) / ((float)tex.height / tex.width); Rect clipRect = rect; if (aspect != 1f) { if (aspect < 1f) { // The sprite is taller than it is wider float padding = cellSize * (1f - aspect) * 0.5f; clipRect.xMin += padding; clipRect.xMax -= padding; } else { // The sprite is wider than it is taller float padding = cellSize * (1f - 1f / aspect) * 0.5f; clipRect.yMin += padding; clipRect.yMax -= padding; } } if (GUI.Button(rect, "")) { mSelectedSprite = MapEx.getString(d, "name"); isShowParckerView = false; currSelectSprite = m; } GUI.DrawTextureWithTexCoords(clipRect, tex, uv); // Draw the selection if (mSelectedSprite == MapEx.getString(d, "name")) { NGUIEditorTools.DrawOutline(rect, new Color(0.4f, 1f, 0f, 1f)); } GUI.backgroundColor = new Color(1f, 1f, 1f, 0.5f); GUI.contentColor = new Color(1f, 1f, 1f, 0.7f); GUI.Label(new Rect(rect.x, rect.y + rect.height, rect.width, 32f), MapEx.getString(d, "name"), "ProgressBarBack"); GUI.contentColor = Color.white; GUI.backgroundColor = Color.white; GUILayout.Space(cellSize + 30); //这句主要目的是为了可以滑动 rect.y += (cellSize + 30); }
void showSpriteInfor() { if (currSelectSprite == null) { return; } Hashtable d = MapEx.getMap(currSelectSprite, "data"); int times = MapEx.getInt(currSelectSprite, "times"); string name = MapEx.getString(d, "name"); string path = MapEx.getString(d, "path"); int x = MapEx.getInt(d, "x"); int y = MapEx.getInt(d, "y"); int width = MapEx.getInt(d, "width"); int height = MapEx.getInt(d, "height"); int borderLeft = MapEx.getInt(d, "borderLeft"); int borderRight = MapEx.getInt(d, "borderRight"); int borderTop = MapEx.getInt(d, "borderTop"); int borderBottom = MapEx.getInt(d, "borderBottom"); int paddingLeft = MapEx.getInt(d, "paddingLeft"); int paddingRight = MapEx.getInt(d, "paddingRight"); int paddingTop = MapEx.getInt(d, "paddingTop"); int paddingBottom = MapEx.getInt(d, "paddingBottom"); Hashtable atlas = MapEx.getMap(currSelectSprite, "atlas"); string atlasStr = ""; foreach (DictionaryEntry item in atlas) { atlasStr = PStr.b().a(atlasStr).a(",").a(item.Key.ToString()).e(); } Texture tex = ECLEditorUtl.getObjectByPath(path) as Texture; Rect r = Rect.zero; if (tex != null) { float h = 0; float w = position.width - 160; float rate = w / tex.width; if (rate < 1) { h = tex.height * rate; } else { h = tex.height; } h = h > 200 ? h : 200; r = new Rect(0, 0, NumEx.getIntPart(w), NumEx.getIntPart(h)); GUI.DrawTexture(r, tex, ScaleMode.ScaleToFit); GUILayout.Space(r.height + r.y); //这句主要目的是为了可以滑动 } else { r = new Rect(0, 0, position.width - 160, 100); GUILayout.Space(r.height + r.y); //这句主要目的是为了可以滑动 } GUILayout.Space(10); ECLEditorUtl.BeginContents(); { EditorGUILayout.BeginHorizontal(); { EditorGUILayout.TextField("name", name); EditorGUILayout.IntField("times", times); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { EditorGUILayout.IntField("x", x); EditorGUILayout.IntField("y", y); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { EditorGUILayout.IntField("width", width); EditorGUILayout.IntField("height", height); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { EditorGUILayout.IntField("borderLeft", borderLeft); EditorGUILayout.IntField("borderRight", borderRight); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { EditorGUILayout.IntField("borderTop", borderTop); EditorGUILayout.IntField("borderBottom", borderBottom); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { EditorGUILayout.IntField("paddingLeft", paddingLeft); EditorGUILayout.IntField("paddingRight", paddingRight); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { EditorGUILayout.IntField("paddingTop", paddingTop); EditorGUILayout.IntField("paddingBottom", paddingBottom); } EditorGUILayout.EndHorizontal(); EditorGUILayout.TextField("path", path); EditorGUILayout.TextField("Atlas", atlasStr); } ECLEditorUtl.EndContents(); }
bool packTextures(int maxSize, bool unityPacking) //, ref ArrayList outSprites, ref Rect[] rects) { if (packTex != null) { DestroyImmediate(packTex, true); packTex = null; } refreshSelectedCount(); if (selectedCount == 0) { Debug.LogError("Please select some sprites, that need packe"); return(false); } packSprites.Clear(); List <Texture2D> listTexs = new List <Texture2D> (); for (int i = 0; i < mSpriteList.Count; i++) { Hashtable m = mSpriteList [i] as Hashtable; if (MapEx.getBool(m, "selected")) { Hashtable d = MapEx.getMap(m, "data"); string name = MapEx.getString(d, "name"); string path = MapEx.getString(d, "path"); Texture2D tex = ECLEditorUtl.getObjectByPath(path) as Texture2D; listTexs.Add(tex); packSprites.Add(m); } } if (sortSprite != SortSprite.none) { if (sortSprite == SortSprite.SortArea) { packSprites.Sort(CompareSprite); } else { packSprites.Sort(CompareSprite2); } listTexs.Clear(); for (int i = 0; i < packSprites.Count; i++) { Hashtable d = MapEx.getMap(packSprites [i], "data"); string path = MapEx.getString(d, "path"); setTextureReadable("Assets/" + path, TextureImporterFormat.RGBA32, TextureImporterCompression.Uncompressed, true); Texture2D tex = ECLEditorUtl.getObjectByPath(path) as Texture2D; listTexs.Add(tex); } } // for (int i = 0; i < listTexs.Count; i++) { // setTextureReadable (listTexs [i] as Texture, TextureImporterFormat.RGBA32, TextureImporterCompression.Uncompressed, true); // } packTex = new Texture2D(1, 1, TextureFormat.ARGB32, false); if (unityPacking) { packRects = packTex.PackTextures(listTexs.ToArray(), NGUISettings.atlasPadding, maxSize); } else { packRects = UITexturePacker.PackTextures(packTex, listTexs.ToArray(), 4, 4, NGUISettings.atlasPadding, maxSize); } _empty = new Texture2D(packTex.width, packTex.height, TextureFormat.ARGB32, false); bool ret = true; for (int i = 0; i < listTexs.Count; ++i) { Rect rect = NGUIMath.ConvertToPixels(packRects [i], packTex.width, packTex.height, true); packRects [i] = rect; // Apparently Unity can take the liberty of destroying temporary textures without any warning if (listTexs [i] == null) { Debug.LogWarning("Apparently Unity can take the liberty of destroying temporary textures without any warning"); ret = false; break; } // Make sure that we don't shrink the textures if (Mathf.RoundToInt(rect.width) != listTexs [i].width) { Debug.LogError(rect.width + "====" + listTexs [i].width); Debug.LogWarning("Make sure that we don't shrink the textures=" + listTexs [i].name); ret = false; break; } } // for (int i = 0; i < listTexs.Count; i++) { // setTextureReadable (listTexs [i] as Texture, TextureImporterFormat.Automatic, false); // } return(ret); }
void showPackerView() { if (packTex != null) { //================= float h = 0; float w = position.width - 160; float rate = w / packTex.width; if (rate < 1) { h = packTex.height * rate; } else { h = packTex.height; } h = h > 512 ? h : 512; Rect r = new Rect(0, 0, NumEx.getIntPart(w), NumEx.getIntPart(h)); NGUIEditorTools.DrawTiledTexture(r, NGUIEditorTools.backdropTexture); if (isShowParckerTextureBg) { GUI.DrawTexture(r, _empty, ScaleMode.ScaleToFit, false); } GUI.DrawTexture(r, packTex, ScaleMode.ScaleToFit); GUILayout.Space(r.height + r.y); //这句主要目的是为了可以滑动 ECLEditorUtl.BeginContents(); { EditorGUILayout.BeginHorizontal(); { EditorGUILayout.IntField("width", packTex.width); EditorGUILayout.IntField("height", packTex.height); } EditorGUILayout.EndHorizontal(); if (GUILayout.Button("Show/Hide Detail")) { showDeltail = !showDeltail; } if (showDeltail) { if (packSprites != null) { Hashtable m = null; Hashtable d = null; Rect _rect; for (int i = 0; i < packSprites.Count; i++) { _rect = packRects [i]; m = packSprites [i] as Hashtable; d = MapEx.getMap(m, "data"); EditorGUILayout.BeginHorizontal(); { EditorGUILayout.LabelField(MapEx.getString(d, "name")); EditorGUILayout.LabelField(Mathf.RoundToInt(_rect.x) + "x" + Mathf.RoundToInt(_rect.y)); EditorGUILayout.LabelField(Mathf.RoundToInt(_rect.width) + "x" + Mathf.RoundToInt(_rect.height)); } EditorGUILayout.EndHorizontal(); } } } } ECLEditorUtl.EndContents(); } isShowParckerTextureBg = EditorGUILayout.ToggleLeft("Show Background", isShowParckerTextureBg); textureSize = (PackerTextureSize)EditorGUILayout.EnumPopup("", textureSize); isUseUnityPacking = EditorGUILayout.ToggleLeft("UnityPacking", isUseUnityPacking); sortSprite = (SortSprite)EditorGUILayout.EnumPopup("", sortSprite); GUILayout.Space(5); GUI.color = Color.yellow; if (GUILayout.Button("Review Pack Texture")) { if (!packTextures((int)textureSize, isUseUnityPacking)) { Debug.LogError("Some errors happened!"); } } GUI.color = Color.white; GUILayout.Space(10); ECLEditorUtl.BeginContents(); { packedName = EditorGUILayout.TextField("Packed Texture Name", string.IsNullOrEmpty(packedName) ? "Packed" + (int)packerSize : packedName); GUI.color = Color.red; removePublishRes = EditorGUILayout.ToggleLeft("Remove Publish AssetsBundle", removePublishRes); if (GUILayout.Button("Apply Pack Texture")) { applyPackTexture((int)textureSize, isUseUnityPacking); } GUI.color = Color.white; } ECLEditorUtl.EndContents(); }