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 DrawItem(Rect rect, HierarchyTreeItemBase item, RowGUIArgs args) { var indent = GetContentIndent(item); rect.width -= indent + 8.0f; rect.x += indent; rect.height = 1; rect.y += 3; UTinyGUI.BackgroundColor(rect, Color.gray); }
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 DropBetweenEntityGroupItems(HierarchyTreeItemBase parent, IEnumerable <IEntityNode> entities, int insertAtIndex) { // Can't add entities before the first group. if (insertAtIndex <= 0) { return; } var graph = (parent.children[insertAtIndex - 1] as HierarchyEntityGroupGraph).Value; graph.Add(entities.ToList()); }
private void DropUponSceneItem(HierarchyTreeItemBase parent, IEnumerable <IEntityNode> entities) { var graph = (parent as HierarchyEntityGroupGraph).Value; foreach (var node in entities) { graph.Add(node); } var ids = AsInstanceIds(entities); Selection.instanceIDs = ids; IdsToExpand = ids; }
private void DropUponStaticEntityItem(HierarchyTreeItemBase parent, IEnumerable <IEntityNode> entities) { var item = (parent as IEntityTreeItem); var parentNode = item.Node as StaticEntityNode; var graph = item.Graph; var staticEntities = entities.OfType <StaticEntityNode>().Where(node => node != parentNode).ToList(); graph.Insert(item.Node.SiblingIndex() + 1, staticEntities); var NonStaticEntities = entities.OfType <EntityNode>().ToList(); graph.Add(NonStaticEntities); }
private void DropUponEntityItem(HierarchyTreeItemBase parent, IEnumerable <IEntityNode> entities) { var item = (parent as IEntityTreeItem); var parentNode = item.Node as EntityNode; var graph = item.Graph; var staticEntities = entities.OfType <StaticEntityNode>().ToList(); graph.Insert(0, staticEntities); var nonStaticEntities = entities.OfType <EntityNode>().ToList(); graph.Insert(-1, nonStaticEntities, parentNode); }
private void DropBetweenRootEntities(HierarchyTreeItemBase parent, IEnumerable <IEntityNode> entities, int insertAtIndex) { var item = parent as HierarchyEntityGroupGraph; var graph = item.Value; { var staticEntities = entities.OfType <StaticEntityNode>().ToList(); if (insertAtIndex < item.children.Count) { var current = item.children[insertAtIndex]; var firstIndex = 0; if (current is HierarchyStaticEntity) { // +1 is for the static separator object. firstIndex = insertAtIndex - (graph.Roots.Count + 1); } foreach (var node in staticEntities) { if (graph.IsRoot(node) && node.SiblingIndex() < firstIndex) { firstIndex -= 1; } graph.Insert(firstIndex++, node); } } else { graph.Add(staticEntities); } } { var nonStaticEntities = entities.OfType <EntityNode>().ToList(); var firstIndex = insertAtIndex; foreach (var node in nonStaticEntities) { if (graph.IsRoot(node) && node.SiblingIndex() < firstIndex) { firstIndex -= 1; } graph.Insert(firstIndex++, node); } } }
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); }
private void DropBetweenChildrenEntities(HierarchyTreeItemBase parent, IEnumerable <IEntityNode> entities, int insertAtIndex) { { var staticEntities = entities.OfType <StaticEntityNode>().ToList(); var graph = (parent as HierarchyEntity).Graph; graph.Insert(0, staticEntities); } { var nonStaticEntities = entities.OfType <EntityNode>().ToList(); var entityNode = (parent as HierarchyEntity).Value; var firstIndex = insertAtIndex; foreach (var node in nonStaticEntities) { if (node.IsChildrenOf(entityNode) && node.SiblingIndex() < firstIndex) { firstIndex -= 1; } entityNode.Insert(firstIndex++, node); } } }
private void DropBetweenStaticEntities(HierarchyTreeItemBase parent, IEnumerable <IEntityNode> entities, int insertAtIndex) { var graph = (parent as HierarchyStaticEntity).Value.Graph; graph.Add(entities.OfType <EntityNode>().ToList()); }