protected override void SingleClickedItem(int id) { HistogrammerTreeViewItem item = FindItem(id); GameObject root = GetRootForSelection(item.SearchResult.Context); EditorGUIUtility.PingObject(root); }
protected override void DoubleClickedItem(int id) { HistogrammerTreeViewItem item = FindItem(id); GameObject root = GetRootForSelection(item.SearchResult.Context); AssetDatabase.OpenAsset(root); }
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(); }
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); }
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; } } }