//-------------------------------------- // PUBLIC METHODS //-------------------------------------- public static Rect RenderNode(int index, TPAtlas antlas, string name) { Vector2 itemPos = new Vector2(); itemPos.y = 25f; if (index + 1 > colItemsCount) { itemPos.y += Mathf.FloorToInt(index / colItemsCount) * TexturePackerStyles.TEXTURE_RECT_SIZE * 1.7f; index = index % colItemsCount; } itemPos.x = itemsSpace / 2f + (index) * (itemsSpace + box_size); GUILayout.BeginArea(new Rect(itemPos.x, itemPos.y, box_size, box_size * 2f), ""); { if (TexturePackerAtlasEditor.selection.Contains(name)) { drawColordeBox(box_size, box_size, Color.green); /* GUILayout.BeginArea (new Rect (box_padding, box_padding , TexturePackerStyles.TEXTURE_RECT_SIZE, TexturePackerStyles.TEXTURE_RECT_SIZE), ""); { * drawColordeBox (TexturePackerStyles.TEXTURE_RECT_SIZE, TexturePackerStyles.TEXTURE_RECT_SIZE); * } GUILayout.EndArea (); */ } else { drawColordeBox(box_size, box_size); } TPAtlasTexture tx = antlas.getTexture(name); tx.draw(getSize(tx), true); string texNmae = string.Empty; if (TPEditorData.isExtensionsEnabled) { texNmae = tx.name; } else { texNmae = tx.nameNoExtention; } string imageInfo = texNmae + "\n(" + tx.width + "x" + tx.height + ")"; GUILayout.Label(imageInfo, TexturePackerStyles.imageLableStyle, TexturePackerStyles.FixedWidthHeight(110f, 40f)); } GUILayout.EndArea(); return(new Rect(itemPos.x, itemPos.y, box_size, box_size)); }
private void renderAtlasPreview() { string[] atlasesNames = TPAssetPostprocessor.atlasesNames; if (atlasesNames.Length == 0) { return; } #if UNITY_4_3 #else EditorGUIUtility.LookLikeInspector(); #endif GUILayout.BeginHorizontal(TexturePackerStyles.toolBarBoxStyle); GUILayout.FlexibleSpace(); EditorGUI.BeginChangeCheck(); if (atlasIndex == -1) { int i = 0; string n = TPEditorData.selectedAtlasName; foreach (string atName in atlasesNames) { if (atName.Equals(n)) { atlasIndex = i; break; } i++; } if (atlasIndex == -1) { atlasIndex = 0; } } atlasIndex = EditorGUI.Popup( new Rect(-10, 0, TexturePackerStyles.ATLAS_POPUP_WIDTH, 20), "", atlasIndex, atlasesNames, TexturePackerStyles.toolBarDropDwonStyle); if (EditorGUI.EndChangeCheck()) { images.Clear(); selection.Clear(); TPEditorData.selectedAtlasName = atlasesNames [atlasIndex]; } GUIStyle btnStyle = EditorStyles.toolbarButton; if (GUILayout.Button("Refresh", btnStyle)) { TPackManager.clear(); TPAssetPostprocessor.UpdateAtlasesInfromation(); } if (GUILayout.Button(addButtonText, btnStyle)) { addSelectedFrameToAnimation(); } if (TPEditorData.isExtensionsEnabled) { btnStyle = TexturePackerStyles.toobarEnabledButton; } if (GUILayout.Button("Extensions", btnStyle)) { TPEditorData.isExtensionsEnabled = !TPEditorData.isExtensionsEnabled; } search = GUILayout.TextField(search, GUI.skin.FindStyle("ToolbarSeachTextField"), TexturePackerStyles.FixedWidth(200f)); if (GUILayout.Button("", GUI.skin.FindStyle("ToolbarSeachCancelButton"))) { // Remove focus if cleared search = ""; GUI.FocusControl(null); } GUILayout.EndHorizontal(); scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(editor.position.width), GUILayout.Height(editor.position.height - 17f)); GUILayout.Box("", GUIStyle.none, new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(_maxY) }); _maxY = 0f; TextureNodeRenderer.calculateVars(editor.position.width - 10f); currentAtlas = getAtlas(atlasesNames[atlasIndex]); Rect r; int index = 0; images.Clear(); foreach (string name in currentAtlas.frameNames) { if (search != string.Empty) { if (!name.ToLower().Contains(search.ToLower())) { continue; } } r = TextureNodeRenderer.RenderNode(index, currentAtlas, name); rememberImageRect(name, r); setNodeY(r.y + r.height * 1.5f); index++; } EditorGUILayout.EndScrollView(); }