/// <summary> /// Constructor of the tree view. /// </summary> public SystemTreeView(string editorWindowInstanceKey) { m_SystemTreeView = new TreeView(m_TreeViewRootItems, Constants.ListView.ItemHeight, MakeTreeViewItem, ReleaseTreeViewItem, BindTreeViewItem) { viewDataKey = $"{Constants.State.ViewDataKeyPrefix}{typeof(SystemScheduleWindow).FullName}+{editorWindowInstanceKey}", selectionType = SelectionType.Single, name = "SystemTreeView", style = { flexGrow = 1 } }; m_SystemTreeView.RegisterCallback <GeometryChangedEvent>(evt => { if (m_ScrollToItemId == -1) { return; } var tempId = m_ScrollToItemId; m_ScrollToItemId = -1; if (m_SystemTreeView.FindItem(tempId) != null) { m_SystemTreeView.ScrollToItem(tempId); } }); m_SystemTreeView.onSelectionChange += OnSelectionChanged; Add(m_SystemTreeView); m_SystemDetailsVisualElement = new SystemDetailsVisualElement(); m_SearchEmptyMessage = new CenteredMessageElement { Title = k_NoSystemsFoundTitle }; m_SearchEmptyMessage.Hide(); Add(m_SearchEmptyMessage); // Create list view for search results. m_SystemListView = new ListView(m_ListViewFilteredItems, Constants.ListView.ItemHeight, MakeListViewItem, ReleaseListViewItem, BindListViewItem) { selectionType = SelectionType.Single, name = "SystemListView", style = { flexGrow = 1 } }; m_SystemListView.RegisterCallback <PointerDownEvent>(evt => { if (evt.button == (int)MouseButton.LeftMouse) { Selection.activeObject = null; } }); #if UNITY_2020_1_OR_NEWER m_SystemListView.onSelectionChange += OnSelectionChanged; #else m_SystemListView.onSelectionChanged += OnSelectionChanged; #endif Add(m_SystemListView); }
public EntityHierarchy(EntityHierarchyFoldingState entityHierarchyFoldingState) { m_EntityHierarchyFoldingState = entityHierarchyFoldingState; style.flexGrow = 1.0f; m_ViewContainer = new VisualElement(); m_ViewContainer.style.flexGrow = 1.0f; m_ViewContainer.RegisterCallback <PointerDownEvent>(evt => { if (evt.button == (int)MouseButton.LeftMouse) { Selection.activeObject = null; } }); m_TreeView = new TreeView(m_TreeViewRootItems, Constants.ListView.ItemHeight, MakeTreeViewItem, ReleaseTreeViewItem, BindTreeViewItem) { selectionType = SelectionType.Single, name = Constants.EntityHierarchy.FullViewName, style = { flexGrow = 1 }, }; m_TreeView.onSelectionChange += OnLocalSelectionChanged; m_TreeView.ItemExpandedStateChanging += (item, isExpanding) => { var entityHierarchyItem = (EntityHierarchyItem)item; if (entityHierarchyItem.NodeId.Kind == NodeKind.Scene || entityHierarchyItem.NodeId.Kind == NodeKind.SubScene) { m_EntityHierarchyFoldingState.OnFoldingStateChanged(entityHierarchyItem.NodeId, isExpanding); } }; m_TreeView.Hide(); m_ViewContainer.Add(m_TreeView); m_ListView = new ListView(m_ListViewFilteredItems, Constants.ListView.ItemHeight, MakeListViewItem, ReleaseListViewItem, BindListViewItem) { selectionType = SelectionType.Single, name = Constants.EntityHierarchy.SearchViewName, style = { flexGrow = 1 } }; m_ListView.Hide(); m_ViewContainer.Add(m_ListView); m_SearchEmptyMessage = new CenteredMessageElement(); m_SearchEmptyMessage.Hide(); Add(m_SearchEmptyMessage); #if UNITY_2020_1_OR_NEWER m_ListView.onSelectionChange += OnLocalSelectionChanged; #else m_ListView.onSelectionChanged += OnSelectionChanged; #endif m_ItemsCache = new HierarchyItemsCache(); m_CurrentViewMode = ViewMode.Full; Add(m_ViewContainer); Selection.selectionChanged += OnGlobalSelectionChanged; }