private bool DrawRowHeader() { bool changed = false; EditorGUILayout.BeginVertical(); changed |= EditorGUILayoutUtil.ObjectField <UITableCell>(ref table.defaultPrefab, true, W_Option, H_Option); EditorGUILayout.LabelField("Align", EditorStyles.boldLabel, H_Option); EditorGUILayout.LabelField("Size", EditorStyles.boldLabel, H_Option); EditorGUILayout.LabelField("Index", EditorStyles.boldLabel, H_Option); int row = table.isVertical? table.GetMaxPerLine(): table.rowCount; table.InitArray(); for (int r = 0; r < row; r++) { EditorGUILayout.BeginHorizontal(); changed |= EditorGUILayoutUtil.ObjectField <UITableCell>(ref table.rowPrefab[r], true, GUILayout.Width(WIDTH - 20), H_Option); changed |= EditorGUILayoutUtil.Popup <UITableLayout.VAlign>(ref table.valigns[r], EnumUtil.Values <UITableLayout.VAlign>(), GUILayout.Width(40), H_Option); changed |= EditorGUILayoutUtil.IntField(null, ref table.rowHeight[r], GUILayout.Width(WIDTH - 30), H_Option); EditorGUILayout.LabelField((r + 1).ToString(), EditorStyles.boldLabel, GUILayout.Width(20), H_Option); EditorGUILayout.EndHorizontal(); } if (!IsHorizontal()) { EditorGUILayout.LabelField("", W_Option); EditorGUILayout.LabelField("", W_Option); EditorGUILayout.LabelField("", W_Option); } EditorGUILayout.EndVertical(); if (changed) { table.InitArray(); } return(changed); }
private bool DrawColumn() { bool changed = false; int columnSize = table.isHorizontal? table.GetMaxPerLine(): table.columnCount; int contentSize = table.columnCount; for (int c = 0; c < columnSize; c++) { EditorGUILayout.BeginVertical(); changed |= EditorGUILayoutUtil.ObjectField <UITableCell>(ref table.columnPrefab[c], true, GUILayout.ExpandWidth(false), H_Option); changed |= EditorGUILayoutUtil.Popup <UITableLayout.HAlign>(ref table.haligns[c], EnumUtil.Values <UITableLayout.HAlign>(), GUILayout.Width(WIDTH - 20), H_Option); changed |= EditorGUILayoutUtil.IntField(null, ref table.columnWidth[c], GUILayout.Width(WIDTH - 20), H_Option); EditorGUILayout.LabelField(c.ToString(), EditorStyles.boldLabel, W_Option, H_Option); int row = table.rowCount; if (c < contentSize) { for (int r = 0; r < row; r++) { changed |= DrawCell(r, c); } // Draw Column +/- buttons EditorGUILayout.BeginHorizontal(); if (GUILayout.Button(new GUIContent("A", "Add Selected"), GUILayout.ExpandWidth(false), H_Option)) { AddSelected(c, UITableLayout.Arrangement.Vertical); changed = true; } if (GUILayout.Button("+", GUILayout.ExpandWidth(false), H_Option)) { #pragma warning disable 0618 table.AddColumn(c + 1, new UITableCell[table.rowCount]); #pragma warning restore 0618 changed = true; } GUI.enabled = c >= table.columnHeader; if (GUILayout.Button("-", GUILayout.ExpandWidth(false), H_Option)) { if (EditorUtility.DisplayDialog("Confirm", "Delete column " + (c + 1), "OK", "Cancel")) { #pragma warning disable 0618 table.RemoveColumn(c); #pragma warning restore 0618 table.Reposition(); changed = true; } } GUI.enabled = true; EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); } return(changed); }
public override void OnFooterGUI() { if (atlasFrom != null && atlasTo != null) { if (duplicateSprites.Count > 0) { if (GUILayout.Button(atlasFrom.name + " -> " + atlasTo.name)) { SwitchAtlas(); } } NGUIEditorTools.DrawSeparator(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); EditorGUILayoutUtil.Popup <string>("Sprite From", ref spriteName1, atlasFrom.GetListOfSprites().ToArray()); EditorGUILayoutUtil.Popup <string>("Sprite To", ref spriteName2, atlasTo.GetListOfSprites().ToArray()); EditorGUILayout.EndVertical(); if (GUILayout.Button("Replace", GUILayout.ExpandWidth(false), GUILayout.Height(30))) { SwitchSprite(spriteName1, spriteName2); } EditorGUILayout.EndHorizontal(); } }
public override void OnInspectorGUI() { if (EditorUI.DrawHeader("Sprite -> Texture")) { EditorUI.BeginContents(); EditorGUILayout.BeginHorizontal(); EditorGUILayoutUtil.ObjectField <Object>("Folder", ref texFolder, false); if (GUILayout.Button("Sprite -> Texture") && EditorUtility.DisplayDialog("Warning", "BackUp?", "OK", "Cancel")) { ConvertToTexture(texFolder); } EditorGUILayout.EndHorizontal(); var drawer = new ListDrawer <UITexture>(texList, new ObjListItemDrawer <UITexture>()); drawer.Draw(); EditorUI.EndContents(); } if (EditorUI.DrawHeader("Texture -> Sprite")) { EditorUI.BeginContents(); EditorGUILayout.BeginHorizontal(); ComponentSelector.Draw <NGUIAtlas>("Atlas", atlasToAdd, OnSelectAtlas, true, GUILayout.MinWidth(80f)); if (GUILayout.Button("Add Selected")) { foreach (Object o in Selection.objects) { if (o is GameObject) { OnSelectAtlas((o as GameObject).GetComponent <NGUIAtlas>()); } } } EditorGUILayout.EndHorizontal(); EditorGUILayoutUtil.TextField("Search sprite", ref searchSpriteName); if (!searchSpriteName.IsEmpty()) { List <NGUIAtlas> filtered = new List <NGUIAtlas>(); foreach (NGUIAtlas a in atlasRefs) { if (a.GetSprite(searchSpriteName) != null) { filtered.Add(a); } } var drawer = new ListDrawer <NGUIAtlas>(filtered, new ObjListItemDrawer <NGUIAtlas>()); drawer.Draw(); EditorGUILayout.BeginHorizontal(); EditorGUILayoutUtil.Popup("Change to", ref changeAtlas, filtered); if (GUILayout.Button("Apply")) { EditorTraversal.ForEachAsset <GameObject>(FileType.Prefab, (path, prefab) => { ChangeAtlas(prefab, filtered, changeAtlas); }); EditorTraversal.ForEachScene(s => { foreach (var r in s.GetRootGameObjects()) { ChangeAtlas(r.gameObject, filtered, changeAtlas); } return(null); }); } EditorGUILayout.EndHorizontal(); var spriteDrawer = new ListDrawer <UISprite>(spriteList, new ObjListItemDrawer <UISprite>()); spriteDrawer.Draw(); } else { var drawer = new ListDrawer <NGUIAtlas>(atlasRefs, new ObjListItemDrawer <NGUIAtlas>()); if (drawer.Draw()) { SaveAtlasRefs(); } } if (!dupSprites.IsEmpty()) { if (EditorUI.DrawHeader("Duplicate sprites")) { EditorUI.BeginContents(); float cellWidth = 200f; float width = GetWidth(); int column = Mathf.Max((int)(width / cellWidth), 1); int i = 0; foreach (string d in dupSprites) { if (i == 0) { EditorGUILayout.BeginHorizontal(); } if (GUILayout.Button(d, GUILayout.Width(200))) { searchSpriteName = d; } i = i + 1; if (i == column) { EditorGUILayout.EndHorizontal(); i = 0; } } if (i != 0) { EditorGUILayout.EndHorizontal(); } EditorUI.EndContents(); } } EditorGUILayout.BeginHorizontal(); EditorGUILayoutUtil.ObjectField("Target", ref targetObj, true); GUI.enabled = targetObj != null; if (GUILayout.Button("Convert to Sprite") && EditorUtility.DisplayDialog("Warning", "BackUp?", "OK")) { ConvertToSprite(); } if (GUILayout.Button("Set TexSetter")) { foreach (UITexture tex in targetObj.GetComponentsInChildren <UITexture>(true)) { TexSetterInspector.SetIfCdn(tex); } } GUI.enabled = true; EditorGUILayout.EndHorizontal(); // collect atlas GUI.enabled = targetObj != null; if (EditorUI.DrawHeader("Member Atlases")) { EditorUI.BeginContents(); if (targetObj != null) { MultiMap <NGUIAtlas, UISprite> collect = new MultiMap <NGUIAtlas, UISprite>(); foreach (UISprite s in targetObj.GetComponentsInChildren <UISprite>(true)) { collect.Add(s.atlas as NGUIAtlas, s); } foreach (KeyValuePair <NGUIAtlas, List <UISprite> > pair in collect) { if (EditorGUILayout.Foldout(folding.Contains(pair.Key), pair.Key.name())) { folding.Add(pair.Key); EditorGUI.indentLevel++; foreach (UISprite s in pair.Value) { EditorGUILayout.ObjectField(s.gameObject, typeof(GameObject), true); } EditorGUI.indentLevel--; } else { folding.Remove(pair.Key); } } } EditorUI.EndContents(); } if (EditorUI.DrawHeader("Orphan Texture")) { EditorUI.BeginContents(); if (targetObj != null) { foreach (UITexture tex in targetObj.GetComponentsInChildren <UITexture>(true)) { if (tex.GetComponent <TexLoader>() == null) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.ObjectField(tex.gameObject, typeof(GameObject), true); EditorGUILayout.ObjectField(tex.mainTexture, typeof(Texture), false); EditorGUILayout.EndHorizontal(); } } } EditorUI.EndContents(); } GUI.enabled = true; EditorUI.EndContents(); } if (EditorUI.DrawHeader("Find All Sprites")) { EditorUI.BeginContents(); EditorGUILayout.BeginHorizontal(); ComponentSelector.Draw <NGUIAtlas>("Atlas", atlas4Sprite, OnSelectAtlasForSprite, true, GUILayout.MinWidth(80f)); if (GUILayout.Button("Find")) { var list = Resources.FindObjectsOfTypeAll <UISprite>().ToList(i => i as UISprite); s4a.Clear(); foreach (var s in list) { if (s.atlas == atlas4Sprite) { s4a.Add(s); } } } EditorGUILayout.EndHorizontal(); EditorUI.EndContents(); } GUI.enabled = true; }