Beispiel #1
0
        protected override AdvancedDropdownItem BuildRoot()
        {
            var rootItem = new AdvancedDropdownItem(m_Title);

            foreach (var column in m_Columns)
            {
                var path   = column.path;
                var pos    = path.LastIndexOf('/');
                var name   = pos == -1 ? column.name : path.Substring(pos + 1);
                var prefix = pos == -1 ? null : path.Substring(0, pos);

                AdvancedDropdownItem newItem = new AdvancedDropdownItem(name)
                {
                    icon        = column.content.image as Texture2D,
                    displayName = string.IsNullOrEmpty(column.content.text) ? column.content.tooltip : SearchColumn.ParseName(column.content.text),
                    tooltip     = column.content.tooltip,
                    userData    = column
                };

                m_ColumnIndexes[newItem.id] = column;

                var parent = rootItem;
                if (prefix != null)
                {
                    parent = MakeParents(prefix, column, rootItem);
                }

                if (FindItem(name, parent) == null)
                {
                    parent.AddChild(newItem);
                }
            }

            rootItem.SortChildren(SortColumnProviders);
            foreach (var c in rootItem.children)
            {
                c.SortChildren(SortColumns, true);
            }
            return(rootItem);
        }