コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
ファイル: UIDepthTab.cs プロジェクト: mulova/ngui_extensions
        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;
        }
コード例 #8
0
        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);
        }