public override void OnGUI() { GUILayout.BeginHorizontal(); GUILayout.BeginVertical(); sidebarScrollPos = EditorGUILayout.BeginScrollView(sidebarScrollPos); for (int i = 0; i < selectionLabels.Length; i++) { if (GUILayout.Toggle(i == selection, selectionLabels[i], EditorStyles.toolbarButton, GUILayout.Width(sidebarWidth))) { selection = i; } } EditorGUILayout.EndScrollView(); GUILayout.EndVertical(); EditorGUILayoutUtil.DrawLine(false, 2); GUILayout.BeginVertical(); if (selection == 0) { Editor editor = Editor.CreateEditor(TenaciousEditorSettings.GetOrCreateSettings()); editor.DrawHeader(); editor.OnInspectorGUI(); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); }
public override void OnInspectorGUI() { GUI.enabled = true; EditorGUILayout.BeginHorizontal(); if (EditorGUILayoutUtil.ObjectField <UIRoot>("Root", ref root, true)) { Classify(ref root); } if (GUILayout.Button("Refresh", GUILayout.ExpandWidth(false)) || root == null) { Classify(ref root); } GUI.enabled = root != null; if (GUILayout.Button("Rename", GUILayout.ExpandWidth(false))) { Rename(); } GUI.enabled = true; EditorGUILayout.EndHorizontal(); scroll = EditorGUILayout.BeginScrollView(scroll); VisualizeGroup(); EditorGUILayoutUtil.DrawSeparator(); VisualizeDups(); EditorGUILayout.EndScrollView(); }
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 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); }
private bool DrawTableStructure() { bool changed = false; if (NGUIEditorTools.DrawHeader("Table Structure")) { NGUIEditorTools.BeginContents(); EditorGUILayout.HelpBox("Modifying structure values may occur unintented result", MessageType.Warning); changed = EditorGUILayoutUtil.PopupEnum <UITableLayout.Arrangement>("Orientation", ref grid.arrangement, GUILayout.ExpandWidth(false)); string rowCol = grid.isHorizontal? "Column Size": "Row Size"; if (EditorGUILayoutUtil.IntField(rowCol, ref grid.maxPerLine, GUILayout.ExpandWidth(false))) { if (grid.maxPerLine <= 0) { grid.maxPerLine = 1; } changed = true; } changed |= EditorGUILayoutUtil.IntField("Row Header", ref grid.rowHeader, GUILayout.ExpandWidth(false)); changed |= EditorGUILayoutUtil.IntField("Column Header", ref grid.columnHeader, GUILayout.ExpandWidth(false)); changed |= EditorGUILayoutUtil.Toggle("Reuse Cell", ref grid.reuseCell, GUILayout.ExpandWidth(false)); NGUIEditorTools.EndContents(); } if (changed) { grid.InitArray(); } return(changed); }
public bool OnInspectorGUI() { Animation anim = script.GetComponent <Animation>(); bool changed = false; EditorGUI.indentLevel++; foreach (string varName in clipVars) { AnimationClip val = script.GetFieldValue <AnimationClip>(varName); if (anim != null) { if (EditorGUILayoutUtil.PopupNullable(varName, ref val, anim.GetAllClips().ToArray())) { script.SetFieldValue(varName, val); changed = true; } } else { if (val != null) { script.SetFieldValue <AnimationClip>(varName, null); changed = true; } } } EditorGUI.indentLevel--; if (changed) { EditorUtil.SetDirty(script); } return(changed); }
public void OnInspectorGUI() { if (EditorGUILayoutUtil.ObjectField <GameObject>("Empty Obj", ref grid.emptyObj, true)) { EditorUtil.SetDirty(grid.emptyObj); } OnGridGUI(); }
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); }
public static void PreferenceMenu() { bool di = DiService.enableDi; if (EditorGUILayoutUtil.Toggle("enable DI", ref di)) { DiService.enableDi = di; Save(); } }
private void DrawFindLexiconGUI() { EditorGUILayout.BeginHorizontal(); EditorGUILayoutUtil.TextField("Lexicon Keys", ref lexiconKeys); if (GUILayout.Button("Find") && !lexiconKeys.IsEmpty()) { Debug.Log(UIBuildScript.FindTextKey(lexiconKeys)); } EditorGUILayout.EndHorizontal(); }
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); }
private bool DrawCell(int r, int c) { bool changed = false; UITableCell cell = table.GetCell(r, c); if (EditorGUILayoutUtil.ObjectField <UITableCell>(ref cell, true, W_Option, GUILayout.Height(HEIGHT - 1))) { table.SetCell(r, c, cell); changed = true; } return(changed); }
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() { bool changed = EditorGUILayoutUtil.ObjectField <GameObject>("Scene Root", ref sceneRoot, true); changed |= EditorGUILayoutUtil.ObjectField <UIAtlas>("From", ref atlasFrom, false); changed |= EditorGUILayoutUtil.ObjectField <UIAtlas>("To", ref atlasTo, false); NGUIEditorTools.DrawSeparator(); if (changed && atlasFrom != null && atlasTo != null) { duplicateSprites = FindDuplicate(atlasFrom, atlasTo); } }
private bool DrawAddColumn() { showAddColumn = EditorGUILayout.Foldout(showAddColumn, "Add Column"); if (showAddColumn) { if (!grid.isHorizontal) { EditorGUILayout.HelpBox("Currently only Horizontal grid type is supported", MessageType.Warning); return(false); } EditorGUILayoutUtil.ObjectField <UILabel>("Title Label(Prefab)", ref titleLabelPrefab, true, GUILayout.ExpandWidth(false)); if (EditorGUILayoutUtil.PopupNullable <GridStyle>(null, ref currentStyle, gridStyles)) { selectedColumn = null; return(true); } if (GUILayout.Button("Apply")) { grid.totalWidth = currentStyle.width; Vector2 minSize = grid.cellMinSize; minSize.y = currentStyle.rowHeight; grid.cellMinSize = minSize; } if (currentStyle != null) { EditorGUILayoutUtil.PopupNullable <ColumnWidth>(null, ref selectedColumn, currentStyle.columnWidth); GUI.enabled = titleLabelPrefab != null && selectedColumn != null; if (GUILayout.Button("Add")) { int lastCol = GetLastColumn(); for (int r = 1, max = grid.rowHeader; r < max; r++) { UITableCell cell = null; #pragma warning disable 0618 grid.Insert((lastCol + 1) * r - 1, cell); #pragma warning restore 0618 } grid.maxPerLine = Math.Max(lastCol + 1, grid.maxPerLine); grid.InitArray(); grid.columnWidth[lastCol] = selectedColumn.width; grid.SetCell(grid.rowHeader - 1, lastCol, CreateLabel(selectedColumn.name, lastCol + 1)); return(true); } } } return(false); }
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 void OnGUI() { DrawLocalizationSelect(); EditorGUILayout.Space(); EditorGUILayoutUtil.DrawUILine(Color.white, width: position.size.x); EditorGUILayout.Space(); _drawCheckHelper(); EditorGUILayout.Space(); EditorGUILayoutUtil.DrawUILine(Color.white, width: position.size.x); EditorGUILayout.Space(); _drawToggle(ToRectKey); _drawToggle(IncludeInactive); }
private bool DrawSize() { bool changed = false; if (NGUIEditorTools.DrawHeader("Size")) { NGUIEditorTools.BeginContents(); if (EditorGUILayoutUtil.PopupEnum <UITableLayout.HAlign>("Horizontal Align", ref grid.halign, GUILayout.ExpandWidth(false))) { for (int i = 0; i < grid.haligns.Length; ++i) { grid.haligns[i] = grid.halign; } changed = true; } if (EditorGUILayoutUtil.PopupEnum <UITableLayout.VAlign>("Vertical Align", ref grid.valign, GUILayout.ExpandWidth(false))) { for (int i = 0; i < grid.valigns.Length; ++i) { grid.valigns[i] = grid.valign; } changed = true; } changed |= EditorGUILayoutUtil.Vector2Field("Padding", ref grid.padding); if (grid.cellMinSize.x == 0 && grid.cellMinSize.y == 0) { changed |= EditorGUILayoutUtil.Vector2Field("Cell Size", ref grid.cellSize); } if (grid.cellSize.x == 0 && grid.cellSize.y == 0) { changed |= EditorGUILayoutUtil.Vector2Field("Cell Min Size", ref grid.cellMinSize); } changed |= EditorGUILayoutUtil.IntField("Total Width", ref grid.totalWidth); changed |= EditorGUILayoutUtil.Toggle("Resize Collider", ref grid.resizeCollider, GUILayout.ExpandWidth(false)); if (grid.resizeCollider && grid.padding != Vector2.zero) { EditorGUI.indentLevel += 1; changed |= EditorGUILayoutUtil.Toggle("Expand Collider To Padding", ref grid.expandColliderToPadding, GUILayout.ExpandWidth(false)); EditorGUI.indentLevel -= 1; } NGUIEditorTools.EndContents(); } return(changed); }
private bool DrawTableHeader() { bool changed = false; EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Size", GUILayout.Width(WIDTH + 10)); int col = grid.columnCount; for (int c = 0; c < col; c++) { EditorGUILayout.LabelField(c.ToString(), EditorStyles.boldLabel, GUILayout.Width(30)); changed |= EditorGUILayoutUtil.IntField(null, ref grid.columnWidth[c], GUILayout.Width(WIDTH - 30)); } if (grid.isHorizontal) { EditorGUILayout.LabelField("", GUILayout.Width(42)); } EditorGUILayout.EndHorizontal(); return(changed); }
public override void OnHeaderGUI() { EditorGUILayoutUtil.ObjectField <LexiconRegistry>("Lexicon Registry", ref lexReg, false); if (lexReg == null) { return; } EditorGUILayoutUtil.PopupEnum <SystemLanguage>("Mother language", ref motherLang); EditorGUILayoutUtil.PopupEnum <SystemLanguage>("Language", ref lang); fold = EditorGUILayout.Foldout(fold, "Translate All"); if (fold) { if (GUILayout.Button("Convert all Scene and prefab") && EditorUtility.DisplayDialog("Confirm", "Convert All?", "OK", "Cancel")) { Lexicon.SetMotherLanguage(motherLang); Lexicon.SetLanguage(lang); TranslateLanguage(); } } EditorGUILayoutUtil.Toggle("Lock", ref locked); if (EditorGUILayoutUtil.Toggle("Visible Only", ref visibleOnly)) { roots = null; } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Reload Table", GUILayout.Height(30))) { ReloadTable(); ApplyTableToText(); } if (GUILayout.Button("Apply table to text", GUILayout.Height(30))) { ApplyTableToText(); } if (GUILayout.Button("Revert", GUILayout.Height(30))) { Clear(); } EditorGUILayout.EndHorizontal(); DrawFindLexiconGUI(); }
public override void OnInspectorGUI() { if (inspector.OnInspectorGUI()) { rq.Optimize(); } showZ = EditorGUILayout.BeginToggleGroup("Z Transform", showZ); if (showZ) { EditorGUI.indentLevel += 2; EditorGUILayoutUtil.FloatField("Z Base", ref rq.zBase); EditorGUILayoutUtil.FloatField("Z Scale", ref rq.zScale); EditorGUI.indentLevel -= 2; } EditorGUILayout.EndToggleGroup(); Dictionary <string, bool> nameSet = new Dictionary <string, bool>(); Dictionary <int, bool> rqSet = new Dictionary <int, bool>(); foreach (RenderQueueElement e in rq.row) { if (string.IsNullOrEmpty(e.name)) { continue; } if (nameSet.ContainsKey(e.name)) { EditorGUILayout.HelpBox("Duplicate " + e.name, MessageType.Error); break; } else if (rqSet.ContainsKey(e.value)) { EditorGUILayout.HelpBox("Duplicate " + e.value, MessageType.Error); break; } nameSet.Add(e.name, true); rqSet.Add(e.value, true); } }
protected override bool OnInspectorGUI(UITab tab, int i) { bool changed = base.OnInspectorGUI(tab, i); if (tab != null && selectTab) { bool visible = tab.IsVisible(); if (EditorGUILayoutUtil.Toggle(null, ref visible, GUILayout.Width(30))) { changed = true; for (int j = 0; j < Length; ++j) { UITab t = this[j] as UITab; if (tab != t) { t.uiRoot.SetActive(false); } EditorUtil.SetDirty(t.gameObject); } tab.uiRoot.SetActive(true); } } 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(); } }
private void DrawNodeInspector(Node node, NodeViewData nodeViewData) { nodeViewData.name = EditorGUILayout.TextField(nodeViewData.name); // Node Delegate Button + Fields EditorGUILayout.BeginVertical((GUIStyle)"InspectorBigBox"); EditorGUILayout.LabelField("Node Delegates:"); foreach (INodeDelegate nodeDelegate in node.GetNodeDelegates()) { Type nodeDelegateType = nodeDelegate.GetType(); EditorGUILayout.BeginVertical((GUIStyle)"InspectorBox"); EditorGUILayout.LabelField(nodeDelegateType.Name, EditorStyles.boldLabel); FieldInfo[] fields = TypeUtil.GetInspectorFields(nodeDelegateType); foreach (FieldInfo field in fields) { EditorGUILayoutUtil.DynamicField(field, nodeDelegate); } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); } if (GUILayout.Button("", (GUIStyle)"AddButton", GUILayout.Width(20.0f), GUILayout.Height(20.0f))) { GenericMenu nodeDelegateMenu = new GenericMenu(); foreach (Type nodeDelegateType in INodeDelegateUtil.ImplementationTypes) { nodeDelegateMenu.AddItem(new GUIContent(nodeDelegateType.Name), false, this.AddNodeDelegateToNode, Tuple.Create(node, nodeDelegateType)); } nodeDelegateMenu.ShowAsContext(); } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); // Node Transitions EditorGUILayout.BeginVertical((GUIStyle)"InspectorBigBox"); EditorGUILayout.LabelField("Transitions:"); IList <NodeTransition> nodeTransitions = this.TargetGraph.GetOutgoingTransitionsForNode(node); foreach (NodeTransition nodeTransition in nodeTransitions) { GUIStyle transitionStyle = this.IsNodeTransitionSelected(nodeTransition) ? (GUIStyle)"SelectedInspectorBox" : (GUIStyle)"InspectorBox"; Rect transitionRect = EditorGUILayout.BeginVertical(transitionStyle, GUILayout.MinHeight(30.0f)); string targetText = ""; targetText += (nodeTransition.targets.Length > 1) ? "Targets: " : "Target: "; targetText += StringUtil.Join(", ", nodeTransition.targets.Select(id => this.GetViewDataForNode(this.TargetGraph.LoadNodeById(id)).name)); EditorGUILayout.LabelField(targetText, GUILayout.Height(30.0f)); Rect editButtonRect = new Rect(new Vector2(transitionRect.x + transitionRect.width - 25.0f, transitionRect.y + 5.0f), new Vector2(20.0f, 20.0f)); if (GUI.Button(editButtonRect, "", (GUIStyle)"EditButton")) { this.StartEditingNodeTransition(node, nodeTransition); } Rect removeButtonRect = new Rect(new Vector2(transitionRect.x + transitionRect.width - 50.0f, transitionRect.y + 5.0f), new Vector2(20.0f, 20.0f)); if (GUI.Button(removeButtonRect, "", (GUIStyle)"RemoveButton")) { this.AddPendingNodeTransitionRemoval(node, nodeTransition); } EditorGUILayout.LabelField("Conditions: "); Transition transition = nodeTransition.transition; transition.WaitForManualExit = EditorGUILayout.Toggle("WaitForManualExit: ", transition.WaitForManualExit); foreach (ITransitionCondition transitionCondition in transition.GetTransitionConditions()) { EditorGUILayout.BeginVertical(transitionStyle); Type transitionConditionType = transitionCondition.GetType(); EditorGUILayout.LabelField(transitionConditionType.Name, EditorStyles.boldLabel); FieldInfo[] fields = TypeUtil.GetInspectorFields(transitionConditionType); foreach (FieldInfo field in fields) { EditorGUILayoutUtil.DynamicField(field, transitionCondition); } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); } if (GUILayout.Button("", (GUIStyle)"AddButton", GUILayout.Width(20.0f), GUILayout.Height(20.0f))) { GenericMenu nodeDelegateMenu = new GenericMenu(); foreach (Type transitionConditionType in TypeUtil <ITransitionCondition> .ImplementationTypes) { nodeDelegateMenu.AddItem(new GUIContent(transitionConditionType.Name), false, this.AddTransitionCondition, Tuple.Create(nodeTransition, transitionConditionType)); } nodeDelegateMenu.ShowAsContext(); } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); } if (GUILayout.Button("", (GUIStyle)"AddButton", GUILayout.Width(20.0f), GUILayout.Height(20.0f))) { this.MakeTransition(node); } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); }
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; }
public override void OnHeaderGUI() { Validate(); EditorGUILayout.BeginHorizontal(); if (EditorGUILayoutUtil.ObjectField <GameObject>("Root", ref root, true)) { Refresh(); } GUI.enabled = root != null; if (GUILayout.Button("Refresh", GUILayout.ExpandWidth(false))) { Refresh(); } GUI.enabled = true; EditorGUILayout.EndHorizontal(); UIPanel[] panels = root != null?root.GetComponentsInChildren <UIPanel>(true) : new UIPanel[0]; EditorGUILayout.BeginHorizontal(); if (EditorGUILayoutUtil.PopupNullable("Panel", ref panelSel, panels, ObjToString.DefaultToString)) { Refresh(); if (panelSel != null) { EditorGUIUtility.PingObject(panelSel); Selection.activeGameObject = panelSel.gameObject; } } EditorGUILayoutUtil.Toggle("Show Active Only", ref showActiveOnly); EditorGUILayout.EndHorizontal(); INGUIAtlas[] atlases = GetAtlases(widgets); INGUIFont[] fonts = GetFonts(widgets); if (EditorGUILayoutUtil.PopupNullable("Select Atlas", ref atlasSel, atlases, ObjToString.DefaultToString)) { if (atlasSel != null) { fontSel = null; } } if (EditorGUILayoutUtil.PopupNullable("Select Font", ref fontSel, fonts, ObjToString.DefaultToString)) { if (fontSel != null) { atlasSel = null; } } EditorGUILayout.BeginHorizontal(); int index = Array.FindIndex(widgets, w => w.gameObject == Selection.activeGameObject); GUI.enabled = index >= 0; if (GUI.enabled) { if (GUILayout.Button("+1 over selection")) { for (int i = 0; i <= index; ++i) { widgets[i].depth = widgets[i].depth + 1; EditorUtil.SetDirty(widgets[i]); } } if (GUILayout.Button("-1 under selection")) { for (int i = index; i < widgets.Length; ++i) { widgets[i].depth = widgets[i].depth - 1; EditorUtil.SetDirty(widgets[i]); } } // TODOM key handling var e = Event.current; if (e.type == EventType.KeyUp) { if (e.keyCode == KeyCode.UpArrow) { index--; if (index >= 0) { Select(widgets[index]); } } else if (e.keyCode == KeyCode.DownArrow) { index++; if (index < widgets.Length) { Select(widgets[index]); } } } } GUI.enabled = true; EditorGUILayout.EndHorizontal(); }
public override void OnInspectorGUI() { object current = null; Color contentColor = GUI.contentColor; Color bgColor = GUI.backgroundColor; Color c1 = BG_COLOR1; Color c2 = BG_COLOR1; foreach (UIWidget w in widgets) { if (w.GetType() == typeof(UIWidget) || w.gameObject == null) { continue; } UISprite s = w as UISprite; UILabel l = w as UILabel; UITexture t = w as UITexture; int depth = w.depth; #pragma warning disable 0253 bool toggle = false; if (s != null) { if (s.atlas == null) { continue; } if (s.atlas != current) { current = s.atlas; toggle = true; } } else if (l != null) { if (l.bitmapFont != current) { current = l.bitmapFont; toggle = true; } } else if (t != null) { if (t.mainTexture != current) { current = t.mainTexture; toggle = true; } } else { toggle = true; current = null; } #pragma warning restore 0253 if (toggle) { c2 = c2 != BG_COLOR1? BG_COLOR1: BG_COLOR2; } c1 = c2; if (atlasSel != null) { c1 = s != null && s.atlas == atlasSel? SEL_BG_COLOR: BG_COLOR1; } else if (fontSel != null) { c1 = l != null && l.bitmapFont == fontSel? SEL_BG_COLOR: BG_COLOR1; } if (w.gameObject == Selection.activeGameObject) { c1 = SEL_BG_COLOR; } GUI.backgroundColor = c1; if (c1 == BG_COLOR1) { GUI.contentColor = TXT_COLOR1; } else if (c1 == BG_COLOR2) { GUI.contentColor = TXT_COLOR2; } else if (c1 == SEL_BG_COLOR) { GUI.contentColor = SEL_TXT_COLOR; } EditorGUILayout.BeginHorizontal(); string widgetName = w.name; if (s != null) { if (s.atlas != null) { widgetName = string.Format("[ATLAS {0}] {2} ({1})", s.atlas.ToString(), s.spriteName, w.name); } } else if (l != null) { if (l.trueTypeFont != null) { widgetName = string.Format("[TTF {0}] {1}", l.trueTypeFont.name, w.name); } else if (l.bitmapFont != null) { widgetName = string.Format("[BMF {0}] {1}", l.bitmapFont.ToString(), w.name); } else { widgetName = string.Format("FNT {0}", w.name); } } else if (t != null) { if (t.mainTexture != null) { widgetName = string.Format("[TEX {0}] {1}", t.mainTexture.name, t.name); } else { widgetName = string.Format("TEX {0}", t.name); } } bool active = w.gameObject.activeInHierarchy; if (active || !showActiveOnly) { Color fgColor = Color.white; if (!active) { fgColor = INACTIVE_TXT_COLOR; } GUI.contentColor = fgColor; if (GUILayout.Button(widgetName, EditorStyles.objectField)) { Select(w); } if (EditorGUILayoutUtil.IntField(null, ref depth, GUILayout.Width(40))) { w.depth = depth; EditorUtil.SetDirty(w); } } EditorGUILayout.EndHorizontal(); } GUI.backgroundColor = bgColor; GUI.contentColor = contentColor; }
private void DrawTextList() { EditorGUILayoutUtil.DrawSeparator(); if (!locked && !Selection.gameObjects.IsEmpty() && (roots == null || !Enumerable.SequenceEqual(roots, Selection.gameObjects))) { Clear(); // search labels roots = Selection.gameObjects; foreach (GameObject o in roots) { tabs.Clear(); foreach (UITabHandler t in o.GetComponentsInChildren <UITabHandler>(true)) { tabs.Add(new UITabHandlerInspectorImpl(t)); } } foreach (GameObject o in roots) { // remove number labels HashSet <UIText> ignore = new HashSet <UIText>(); foreach (DropDown dropdown in o.GetComponentsInChildren <DropDown>(true)) { foreach (UIText l in dropdown.GetComponentsInChildren <UIText>(true)) { ignore.Add(l); } } foreach (UIText l in o.GetComponentsInChildren <UIText>(true)) { if (l.text.IsEmpty()) { continue; } if (ignore.Contains(l)) { continue; } if (visibleOnly && (!l.gameObject.activeInHierarchy || !l.enabled)) { continue; } foreach (char c in l.text) { if (char.IsLetter(c) && !char.IsWhiteSpace(c) && !char.IsPunctuation(c)) { labels.Add(l); break; } } } } } foreach (UITabHandlerInspectorImpl inspector in tabs) { if (inspector.OnInspectorGUI()) { Save(); roots = null; } } // draw trigger list EditorGUILayout.BeginVertical(); foreach (UIText l in labels) { if (!mod.ContainsKey(l)) { FindKey(l); } EditorGUILayout.BeginHorizontal(); EditorGUILayout.ObjectField(l, typeof(UIText), true); Color oldColor = GUI.backgroundColor; string srcKey = mod.Get(l); if (srcKey == null) { srcKey = l.textKey; } if (!Lexicon.ContainsKey(srcKey)) { GUI.backgroundColor = Color.red; } string dstKey = EditorGUILayout.TextField(srcKey); GUI.backgroundColor = oldColor; string text = EditorGUILayout.TextField(l.text); if (srcKey != dstKey) { mod[l] = dstKey; } if (text != l.text) { l.SetText(text); EditorUtil.SetDirty(l); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); if (GUILayout.Button("Save")) { Save(); } }
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); }
internal void LayoutGUI() { var centeredStyle = new GUIStyle(GUI.skin.GetStyle("Label")); centeredStyle.alignment = TextAnchor.UpperCenter; GUILayout.Label(new GUIContent("Bundle Pack Config"), centeredStyle); EditorGUILayout.Space(); EditorGUILayout.BeginVertical(); { m_PackConfig.OutputDirPath = EditorGUILayoutUtil.DrawDiskFolderSelection("Bundle Output", m_PackConfig.OutputDirPath); if (string.IsNullOrEmpty(m_PackConfig.OutputDirPath)) { m_PackConfig.OutputDirPath = GetDefaultOutputDir(); } m_PackConfig.BuildTarget = (ValidBuildTarget)EditorGUILayout.EnumPopup(m_TargetContent, m_PackConfig.BuildTarget); m_AdvancedSettings = EditorGUILayout.Foldout(m_AdvancedSettings, "Advanced Settings"); if (m_AdvancedSettings) { EditorGUIUtil.BeginIndent(); { m_PackConfig.CleanupBeforeBuild = EditorGUILayout.Toggle(m_CleanBeforeBuildContent, m_PackConfig.CleanupBeforeBuild); m_PackConfig.Compression = (CompressOptions)EditorGUILayout.IntPopup(m_CompressionContent, (int)m_PackConfig.Compression, m_CompressionContents, m_CompressionValues); EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); { m_IsForceRebuild = EditorGUILayout.Toggle(m_ForceRebuildContent, m_IsForceRebuild); m_IsAppendHash = EditorGUILayout.Toggle(m_AppendHashContent, m_IsAppendHash); } if (EditorGUI.EndChangeCheck()) { if (m_IsForceRebuild) { m_PackConfig.BundleOptions |= BuildAssetBundleOptions.ForceRebuildAssetBundle; } else { m_PackConfig.BundleOptions &= ~BuildAssetBundleOptions.ForceRebuildAssetBundle; } if (m_IsAppendHash) { m_PackConfig.BundleOptions |= BuildAssetBundleOptions.AppendHashToAssetBundleName; } else { m_PackConfig.BundleOptions &= ~BuildAssetBundleOptions.AppendHashToAssetBundleName; } } } EditorGUIUtil.EndIndent(); } EditorGUILayout.Space(); if (GUILayout.Button("Pack Bundle")) { EditorApplication.delayCall += () => { BundlePackUtil.PackAssetBundle(m_PackConfig); }; } } EditorGUILayout.EndVertical(); if (GUI.changed) { Util.FileUtil.SaveToBinary <BundlePackConfig>(BundlePackUtil.GetPackConfigPath(), m_PackConfig); } }