Inheritance: System.Attribute
Example #1
0
        private MenuItem AddHierarchy(ref GUIContent content, out string path)
        {
            path = content.text;
            if (path.Contains ("/"))
            { // is inside a group
                string[] subContents = path.Split ('/');
                string folderPath = subContents[0];

                // top level group
                MenuItem parent = menuItems.Find ((MenuItem item) => item.content != null && item.content.text == folderPath);
                if (parent == null)
                    menuItems.Add (parent = new MenuItem (folderPath, new GUIContent (folderPath), true));

                // additional level groups
                for (int groupCnt = 1; groupCnt < subContents.Length-1; groupCnt++)
                {
                    string folder = subContents[groupCnt];
                    folderPath += "/" + folder;
                    MenuItem subGroup = parent.subItems.Find ((MenuItem item) => item.content != null && item.content.text == folder);
                    if (subGroup == null)
                        parent.subItems.Add (subGroup = new MenuItem (folderPath, new GUIContent (folder), true));
                    parent = subGroup;
                }

                // actual item
                path = content.text;
                content = new GUIContent (subContents[subContents.Length-1], content.tooltip);
                return parent;
            }
            return null;
        }
Example #2
0
        private void DrawItem(MenuItem item, Rect groupRect)
        {
            if (item.separator)
            {
                if (Event.current.type == EventType.Repaint)
                    RTEditorGUI.Seperator (new Rect (backgroundStyle.contentOffset.x+1, currentItemHeight+1, groupRect.width-2, 1));
                currentItemHeight += 3;
            }
            else
            {
                Rect labelRect = new Rect (backgroundStyle.contentOffset.x, currentItemHeight, groupRect.width, itemHeight);

                bool selected = selectedPath.Contains (item.path);
                if (labelRect.Contains (Event.current.mousePosition))
                {
                    selectedPath = item.path;
                    selected = true;
                }

                //ImProc: change label style
                GUI.Label(labelRect, item.content, selected ? selectedLabel : nonSelectedLabel);
                //GUI.Label (labelRect, item.content, selected? selectedLabel : GUI.skin.label);

                if (item.group)
                {
                    GUI.DrawTexture (new Rect (labelRect.x+labelRect.width-12, labelRect.y+(labelRect.height-12)/2, 12, 12), expandRight);
                    if (selected)
                    {
                        item.groupPos = new Rect (groupRect.x+groupRect.width+4, groupRect.y+currentItemHeight-2, 0, 0);
                        groupToDraw = item;
                    }
                }
                else if (selected && (Event.current.type == EventType.MouseDown || (Event.current.button != 1 && Event.current.type == EventType.MouseUp)))
                {
                    item.Execute ();
                    close = true;
                    Event.current.Use ();
                }

                currentItemHeight += itemHeight;
            }
        }
Example #3
0
        public void Draw()
        {
            bool inRect = DrawGroup (position, menuItems);

            while (groupToDraw != null && !close)
            {
                MenuItem group = groupToDraw;
                groupToDraw = null;
                if (group.group)
                {
                    if (DrawGroup (group.groupPos, group.subItems))
                        inRect = true;
                }
            }

            if (!inRect || close)
                OverlayGUI.currentPopup = null;

            NodeEditorFramework.NodeEditor.RepaintClients ();
        }