private bool DrawTextMod() { bool changed = false; int row = grid.rowCount; int col = grid.columnCount; mod = EditorGUILayout.Foldout(mod, "Text Mod"); if (mod) { EditorGUI.indentLevel += 2; for (int r = 0; r < row; r++) { EditorGUILayout.BeginHorizontal(); for (int c = 0; c < col; c++) { UITableCell cell = grid.GetCell(r, c); UILabel l = cell != null?cell.GetComponentInChildren <UILabel>() : null; string s = l != null? l.text: ""; if (EditorGUILayoutUtil.TextField(null, ref s, GUILayout.Width(70)) && l != null) { l.SetText(s); changed = true; } } EditorGUILayout.EndHorizontal(); } EditorGUI.indentLevel -= 2; } return(changed); }
protected override bool OnInspectorGUI(RenderQueueElement info, int i) { float width = GetWidth(); bool changed = false; changed |= EditorGUILayoutUtil.TextField(null, ref info.name, GUILayout.MinWidth(width * 0.5F)); changed |= EditorGUILayoutUtil.IntField(null, ref info.value, GUILayout.MinWidth(width * 0.3F)); return(changed); }
private void DrawFindLexiconGUI() { EditorGUILayout.BeginHorizontal(); EditorGUILayoutUtil.TextField("Lexicon Keys", ref lexiconKeys); if (GUILayout.Button("Find") && !lexiconKeys.IsEmpty()) { Debug.Log(UIBuildScript.FindTextKey(lexiconKeys)); } EditorGUILayout.EndHorizontal(); }
public override void OnHeaderGUI(List <Object> found) { EditorGUILayoutUtil.TextArea("Exclude", ref exclude); EditorGUILayoutUtil.Toggle("Exclude TexLoader", ref excludeTexLoader); EditorGUILayout.BeginHorizontal(); EditorGUILayoutUtil.TextField(null, ref filter); if (GUILayout.Button("Search")) { SetExclude(exclude); Search(); } EditorGUILayout.EndHorizontal(); }
public override void OnHeaderGUI() { EditorGUILayoutUtil.ObjectField <GameObject>("Scene Root", ref sceneRoot, true); GUI.enabled = sceneRoot != null; ComponentSelector.Draw("Select", NGUISettings.atlas, OnSelectAtlas, true); EditorGUILayoutUtil.TextField("Filter", ref filter); if (EditorGUILayoutUtil.Toggle("Expand", ref expand)) { foreach (string s in spriteMap.Keys) { foldMap[s] = expand; } } GUI.enabled = true; NGUIEditorTools.DrawSeparator(); }
private bool DrawTest() { showTest = EditorGUILayout.Foldout(showTest, "Test"); bool changed = false; if (showTest) { EditorGUI.indentLevel += 2; EditorGUILayoutUtil.ObjectField <UIFont>("Font", ref testFont, true); int row = grid.rowCount; int col = grid.columnCount; if (EditorGUILayoutUtil.IntField("Font Size", ref fontSize, GUILayout.ExpandWidth(false))) { for (int r = 0; r < row; r++) { for (int c = 0; c < col; c++) { UILabel label = grid.GetCell(r, c).GetComponent <UILabel>(); if (label != null) { label.transform.localScale = new Vector3(fontSize, fontSize, 1); } } } } if (EditorGUILayoutUtil.ColorField("Font Color", ref fontColor, GUILayout.ExpandWidth(false))) { for (int r = grid.rowHeader; r < row; r++) { for (int c = grid.columnHeader; c < col; c++) { UILabel label = grid.GetCell(r, c).GetComponent <UILabel>(); if (label != null) { label.color = fontColor; label.MarkAsChanged(); } } } } Array.Resize(ref testStrings, grid.maxPerLine); for (int i = 0; i < grid.maxPerLine; i++) { EditorGUILayoutUtil.TextField(i.ToString(), ref testStrings[i], GUILayout.ExpandWidth(false)); } GUI.enabled = testFont != null; if (GUILayout.Button("Fill Data")) { for (int r = grid.rowHeader; r < row; r++) { for (int c = grid.columnHeader; c < col; c++) { UITableCell cell = grid.GetCell(r, c); if (cell == null) { UILabel label = NGUITools.AddWidget <UILabel>(grid.gameObject); label.bitmapFont = testFont; label.name = "__TEST__"; label.SetText(testStrings[grid.isHorizontal?c:r]); label.transform.localScale = new Vector3(fontSize, fontSize, 1); label.color = fontColor; label.MarkAsChanged(); UILabelCell lc = label.gameObject.AddComponent <UILabelCell>(); lc.label = label; grid.SetCell(r, c, lc); } } } changed = true; } GUI.enabled = true; EditorGUI.indentLevel -= 2; } return(changed); }
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; }