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(); }
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(); }