protected override TreeViewItem BuildRoot() { var nextId = int.MaxValue; var root = new HierarchyTreeItemBase() { id = nextId--, depth = -1, displayName = "Root" }; if (null == m_EntityGroups || m_EntityGroups.Count == 0) { var item = new TreeViewItem { id = nextId--, depth = 0, displayName = "No group Opened" }; root.AddChild(item); return(root); } foreach (var entityGroupRef in m_EntityGroups) { var graph = UTinyHierarchyWindow.GetSceneGraph(entityGroupRef); if (null == graph) { RemoveEntityGroup(entityGroupRef); continue; } var entityGroup = graph.EntityGroupRef.Dereference(Registry); Assert.IsNotNull(entityGroup); var item = new HierarchyEntityGroupGraph { id = nextId--, depth = 0, displayName = entityGroup.Name, Value = graph }; root.AddChild(item); foreach (var node in graph.Roots) { BuildFromNode(node, item); } if (graph.StaticEntities.Count > 0) { item.AddChild(new HierarchyTreeItemBase { id = nextId--, depth = 1 }); } foreach (var node in graph.StaticEntities) { BuildFromNode(node, item); } } ShouldReload = false; return(root); }
private void BuildFromNode(EntityNode node, HierarchyTreeItemBase parentItem) { var entity = node.Entity.Dereference(m_Context.Registry); var item = new HierarchyEntity { Value = node, id = GetInstanceId(node), depth = parentItem.depth + 1, displayName = entity.Name }; if (entity.Name.IndexOf(FilterString, StringComparison.OrdinalIgnoreCase) >= 0) { parentItem.AddChild(item); } foreach (var child in node.Children) { if (string.IsNullOrEmpty(m_FilterString)) { BuildFromNode(child, item); } else { BuildFromNode(child, parentItem); } } }
private void BuildFromNode(StaticEntityNode node, HierarchyTreeItemBase parentItem) { var entity = node.Entity.Dereference(m_Context.Registry); if (entity.Name.IndexOf(FilterString, StringComparison.OrdinalIgnoreCase) < 0) { return; } var item = new HierarchyStaticEntity { Value = node, id = GetInstanceId(node), depth = parentItem.depth + 1, displayName = entity.Name }; parentItem.AddChild(item); }