public CZMenuTreeViewItem Find(int id) { CZMenuTreeViewItem item = null; treeViewItemMap.TryGetValue(id, out item); return(item); }
protected override void RowGUI(RowGUIArgs args) { Rect lineRect = args.rowRect; lineRect.y += lineRect.height; lineRect.height = 1; EditorGUI.DrawRect(lineRect, new Color(0.5f, 0.5f, 0.5f, 1)); CZMenuTreeViewItem item = args.item as CZMenuTreeViewItem; Rect labelRect = args.rowRect; labelRect.x += item.depth * depthIndentWidth + depthIndentWidth; GUI.Label(labelRect, new GUIContent(item.displayName, item.icon), LabelStype); item.itemDrawer?.Invoke(args.rowRect); }
public CZMenuTreeViewItem AddMenuItem(string _path, Texture2D _icon) { if (string.IsNullOrEmpty(_path)) { return(null); } List <TreeViewItem> current = items; string[] path = _path.Split('/'); if (path.Length > 1) { for (int i = 0; i < path.Length - 1; i++) { CZMenuTreeViewItem currentParent = current.Find(t => t.displayName == path[i]) as CZMenuTreeViewItem; if (currentParent == null) { currentParent = new CZMenuTreeViewItem(path[i]); currentParent.children = new List <TreeViewItem>(); currentParent.displayName = path[i]; currentParent.id = itemCount; current.Add(currentParent); treeViewItemMap[itemCount] = currentParent; itemCount++; } current = currentParent.children; } } CZMenuTreeViewItem item = new CZMenuTreeViewItem(_path); item.id = itemCount; item.displayName = path[path.Length - 1]; item.children = new List <TreeViewItem>(); item.icon = _icon; current.Add(item); treeViewItemMap[itemCount] = item; itemCount++; return(item); }
protected virtual void OnRightGUI(Rect _rect, CZMenuTreeViewItem _selectedItem) { _selectedItem.rightDrawer?.Invoke(_rect); }