Exemple #1
0
        void RecreateItemsToExpand()
        {
            m_TreeViewItemsToExpand.Clear();
            foreach (var treeViewRootItem in m_TreeViewRootItems)
            {
                var hierarchyItem = (EntityHierarchyItem)treeViewRootItem;
                if (hierarchyItem.NodeId.Kind != NodeKind.Scene || EntityHierarchyState.GetFoldingState(hierarchyItem.NodeId) == false)
                {
                    continue;
                }

                m_TreeViewItemsToExpand.Add(hierarchyItem.id);

                if (!hierarchyItem.hasChildren)
                {
                    continue;
                }

                foreach (var childItem in hierarchyItem.Children)
                {
                    if (childItem.NodeId.Kind != NodeKind.SubScene || EntityHierarchyState.GetFoldingState(childItem.NodeId) == false)
                    {
                        continue;
                    }

                    m_TreeViewItemsToExpand.Add(childItem.id);
                }
            }
        }
Exemple #2
0
        protected override void OnWorldSelected(World world)
        {
            if (world == World)
            {
                return;
            }

            State?.Dispose();
            GroupingStrategy?.Dispose();
            m_EntityHierarchyDiffer?.Dispose();

            State                   = null;
            GroupingStrategy        = null;
            m_EntityHierarchyDiffer = null;

            World = world;
            if (World != null)
            {
                // TODO: How do we instantiate the correct State/Strategy combination?
                // TODO: Should we even allow the State to be overridable by users?
                State            = new EntityHierarchyState(world);
                GroupingStrategy = new EntityHierarchyDefaultGroupingStrategy(world, State);

                m_EntityHierarchyDiffer = new EntityHierarchyDiffer(this, DisableDifferCooldownPeriod ? 0 : 16);
                m_EntityHierarchy.Refresh(this);
            }
            else
            {
                m_EntityHierarchy.Clear();
            }
        }
Exemple #3
0
        public EntityHierarchy()
        {
            style.flexGrow = 1.0f;

            m_TreeView = new TreeView(m_TreeViewRootItems, Constants.EntityHierarchy.ItemHeight, OnMakeItem, OnBindItem)
            {
                selectionType = SelectionType.Single,
                name          = Constants.EntityHierarchy.FullViewName
            };
            m_TreeView.style.flexGrow     = 1.0f;
            m_TreeView.onSelectionChange += OnSelectionChanged;
            m_TreeView.RegisterCallback <PointerDownEvent>(evt =>
            {
                if (evt.button == (int)MouseButton.LeftMouse)
                {
                    m_TreeView.ClearSelection();
                }
            });
            m_TreeView.ItemExpandedStateChanging += (item, isExpanding) =>
            {
                var entityHierarchyItem = (EntityHierarchyItem)item;
                if (entityHierarchyItem.NodeId.Kind == NodeKind.Scene || entityHierarchyItem.NodeId.Kind == NodeKind.SubScene)
                {
                    EntityHierarchyState.OnFoldingStateChanged(entityHierarchyItem.NodeId, isExpanding);
                }
            };

            m_ListView = new ListView(m_ListViewFilteredItems, Constants.EntityHierarchy.ItemHeight, OnMakeItem, OnBindListItem)
            {
                selectionType = SelectionType.Single,
                name          = Constants.EntityHierarchy.SearchViewName
            };
            m_ListView.RegisterCallback <PointerDownEvent>(evt =>
            {
                if (evt.button == (int)MouseButton.LeftMouse)
                {
                    m_ListView.ClearSelection();
                }
            });

            m_ListView.style.flexGrow = 1.0f;

#if UNITY_2020_1_OR_NEWER
            m_ListView.onSelectionChange += OnSelectionChanged;
#else
            m_ListView.onSelectionChanged += OnSelectionChanged;
#endif

            m_SelectionProxy           = ScriptableObject.CreateInstance <EntitySelectionProxy>();
            m_SelectionProxy.hideFlags = HideFlags.HideAndDontSave;
            m_SelectionProxy.EntityControlSelectButton += OnSelectionChangedByInspector;

            m_Searcher = new DefaultHierarchySearcher();

            SwitchViewMode(ViewMode.Full);
        }