protected virtual void OnParentChanged(ExposeToEditor obj, ExposeToEditor oldParent, ExposeToEditor newParent) { if (Editor.IsPlaymodeStateChanging) { return; } if (!IsFilterEmpty) { return; } bool isNewParentExpanded = true; bool isOldParentExpanded = true; bool isLastChild = false; if (newParent != null) { isNewParentExpanded = m_treeView.IsExpanded(newParent); } if (oldParent != null) { TreeViewItemContainerData itemContainerData = (TreeViewItemContainerData)m_treeView.GetItemContainerData(oldParent); isLastChild = !oldParent.HasChildren(); //!itemContainerData.HasChildren(m_treeView); isOldParentExpanded = m_treeView.IsExpanded(oldParent); } if (isNewParentExpanded) { m_treeView.ChangeParent(newParent, obj); if (!isOldParentExpanded) { if (isLastChild) { VirtualizingTreeViewItem oldParentContainer = m_treeView.GetTreeViewItem(oldParent); if (oldParentContainer) { oldParentContainer.CanExpand = false; } } } } else { if (newParent != null) { VirtualizingTreeViewItem newParentTreeViewItem = m_treeView.GetTreeViewItem(newParent); if (newParentTreeViewItem != null) { newParentTreeViewItem.CanExpand = true; } } m_treeView.RemoveChild(oldParent, obj); } }
protected virtual void OnItemExpanding(object sender, VirtualizingItemExpandingArgs e) { ExposeToEditor exposeToEditor = (ExposeToEditor)e.Item; if (exposeToEditor.HasChildren()) { e.Children = exposeToEditor.GetChildren().Where(obj => !obj.MarkAsDestroyed); //This line is required to syncronize selection, runtime selection and treeview selection OnTreeViewSelectionChanged(m_treeView.SelectedItems, m_treeView.SelectedItems); } else { e.Children = new ExposeToEditor[0]; } }
protected virtual void Expand(ExposeToEditor item) { if (item == null) { return; } ExposeToEditor parent = item.GetParent(); if (parent != null && !m_treeView.IsExpanded(parent)) { Expand(parent); } if (item.HasChildren()) { m_treeView.Expand(item); } }
protected virtual void OnItemDataBinding(object sender, VirtualizingTreeViewItemDataBindingArgs e) { ExposeToEditor dataItem = (ExposeToEditor)e.Item; if (dataItem != null) { TextMeshProUGUI text = e.ItemPresenter.GetComponentInChildren <TextMeshProUGUI>(true); text.text = dataItem.name; if (dataItem.gameObject.activeInHierarchy) { text.color = m_hierarchyView.EnabledItemColor; } else { text.color = m_hierarchyView.DisabledItemColor; } e.HasChildren = dataItem.HasChildren(); } }