Пример #1
0
        void Select(EntityHierarchyNodeId id)
        {
            m_SelectedItem = id;
            switch (m_CurrentViewMode)
            {
            case ViewMode.Full:
            {
                m_TreeView.Select(id.GetHashCode(), false);
                break;
            }

            case ViewMode.Search:
            {
                var index = m_ListViewFilteredItems.FindIndex(item => item.NodeId == id);
                if (index != -1)
                {
                    m_ListView.ScrollToItem(index);
                    m_CachedSingleSelectionBuffer[0] = index;
                    m_ListView.SetSelectionWithoutNotify(m_CachedSingleSelectionBuffer);
                }

                break;
            }
            }
        }
Пример #2
0
        public static EntityHierarchyItem GetTreeViewItem(ITreeViewItem parent, EntityHierarchyNodeId nodeId, IEntityHierarchy hierarchy)
        {
            var item = Pool <EntityHierarchyItem> .GetPooled();

            item.Initialize(parent, nodeId, hierarchy);
            return(item);
        }
Пример #3
0
        bool TrySelect(EntityHierarchyNodeId id)
        {
            if (id == default || !m_Hierarchy.State.Exists(id))
            {
                if (m_SelectedItem != default)
                {
                    Deselect();
                }

                return(false);
            }

            Select(id);
            return(true);
        }
Пример #4
0
        void OnSelectionChangedByInspector(World world, Entity entity)
        {
            if (world != m_Hierarchy.World)
            {
                return;
            }

            var nodeId = EntityHierarchyNodeId.FromEntity(entity);

            if (!m_Hierarchy.Strategy.Exists(nodeId))
            {
                return;
            }

            Select(nodeId.GetHashCode());
        }
        void IEntityHierarchyGroupingStrategy.ApplyEntityChanges(NativeArray <Entity> newEntities, NativeArray <Entity> removedEntities, IEntityHierarchyGroupingContext context)
        {
            // Remove entities
            foreach (var entity in removedEntities)
            {
                m_State.RegisterRemoveOperation(EntityHierarchyNodeId.FromEntity(entity));
            }

            // Add new entities
            foreach (var entity in newEntities)
            {
                m_State.RegisterAddEntityOperation(entity, out _);
            }

            UpdateMissingParentEntities();
            MoveEntitiesUnderFoundMissingParents();
        }
Пример #6
0
        void OnLocalSelectionChanged(EntityHierarchyItem selectedItem)
        {
            m_SelectedItem = selectedItem.NodeId;
            if (selectedItem.NodeId.Kind == NodeKind.Entity)
            {
                var entity = selectedItem.NodeId.ToEntity();
                if (entity != Entity.Null)
                {
                    var undoGroup = Undo.GetCurrentGroup();
                    EntitySelectionProxy.SelectEntity(m_Hierarchy.World, entity);

                    // Collapsing the selection of the entity into the selection of the ListView / TreeView item
                    Undo.CollapseUndoOperations(undoGroup);
                }
            }
            else
            {
                // TODO: Deal with non-Entity selections
            }
        }
Пример #7
0
 void OnGlobalSelectionChanged()
 {
     if (Selection.activeObject is EntitySelectionProxy selectedProxy && selectedProxy.World == m_Hierarchy.World)
     {
         TrySelect(EntityHierarchyNodeId.FromEntity(selectedProxy.Entity));
     }
Пример #8
0
 void Deselect()
 {
     m_SelectedItem = default;
     m_TreeView.ClearSelection();
     m_ListView.ClearSelection();
 }
 void RenderInvalidNode(EntityHierarchyNodeId nodeId)
 {
     m_NameLabel.text = $"<UNKNOWN> ({nodeId.ToString()})";
 }