예제 #1
0
        protected override void SingleClickedItem(int id)
        {
            HistogrammerTreeViewItem item = FindItem(id);
            GameObject root = GetRootForSelection(item.SearchResult.Context);

            EditorGUIUtility.PingObject(root);
        }
예제 #2
0
        protected override void DoubleClickedItem(int id)
        {
            HistogrammerTreeViewItem item = FindItem(id);
            GameObject root = GetRootForSelection(item.SearchResult.Context);

            AssetDatabase.OpenAsset(root);
        }
예제 #3
0
        public void Initialize(List <SearchResult> results)
        {
            items = new List <TreeViewItem>();

            int id = 0;

            foreach (SearchResult result in results)
            {
                string[] splits = result.Name.Split('/');

                int          depth  = -1;
                TreeViewItem parent = null;
                for (int i = 0; i < splits.Length; i++)
                {
                    string split = splits[i];
                    int    hash  = GetHash(i, splits.Length, result.Context);

                    TreeViewItem treeViewItem;
                    if (!hashToTreeViewItem.TryGetValue(hash, out treeViewItem))
                    {
                        treeViewItem = new HistogrammerTreeViewItem(result)
                        {
                            id          = ++id,
                            depth       = ++depth,
                            displayName = split,
                            icon        = i == splits.Length - 1
                                ? (Texture2D)EditorGUIUtility.ObjectContent(null, typeof(MonoScript)).image
                                : (Texture2D)EditorGUIUtility.ObjectContent(null, typeof(GameObject)).image
                        };

                        hashToTreeViewItem[hash] = treeViewItem;

                        if (i == 0) // Only add top level to the list, others are children
                        {
                            items.Add(treeViewItem);
                        }
                    }
                    else
                    {
                        ++depth;
                    }

                    if (parent != null)
                    {
                        parent.AddChild(treeViewItem);
                    }

                    parent = treeViewItem;
                }
            }

            Reload();
        }
예제 #4
0
        private HistogrammerTreeViewItem FindItem(int id)
        {
            IList <TreeViewItem> rows = FindRows(new List <int> {
                id
            });

            if (rows.Count != 1)
            {
                return(null);
            }

            HistogrammerTreeViewItem item = (HistogrammerTreeViewItem)rows.First();

            return(item);
        }
예제 #5
0
        private void CellGUI(Rect rect, TreeViewItem item, int column, ref RowGUIArgs args)
        {
            HistogrammerTreeViewItem histogrammerTreeViewItem = (HistogrammerTreeViewItem)item;

            switch (column)
            {
            case 0:
            {
                args.rowRect = rect;
                base.RowGUI(args);
                break;
            }

            case 1:
            {
                if (item.depth == 0)
                {
                    EditorGUI.LabelField(rect, histogrammerTreeViewItem.SearchResult.Path);
                }

                break;
            }
            }
        }