private void CreateTrees(SelectionTree tree) { for (var t = 0; t < tree.Labels.Count; t++) { var items = tree.Items[t]; var label = tree.Labels[t]; var root = TreeItem.Branch(string.Empty, label, null); var rootPath = label.text + "/"; var leaves = new List <TreeItem>(); for (var index = 0; index < items.Length; index++) { var node = items[index]; var fullPath = rootPath + node.text; var submenus = fullPath.Split('/'); var path = rootPath; var child = root; for (var i = 1; i < submenus.Length - 1; i++) { var menu = submenus[i]; path += menu + "/"; var previousChild = child; child = GetChild(child, path); if (child == null) { child = TreeItem.Branch(path, new GUIContent(menu, _folderIcon.Content.image), previousChild); } } leaves.Add(TreeItem.Leaf(index, path, new GUIContent(submenus.Last(), node.image ?? _defaultTypeIcon.Content.image), child)); } _roots.Add(root); _searchList.Add(leaves); } }