private void OnParentChanged(ExposeToEditor obj, ExposeToEditor oldParent, ExposeToEditor newParent)
        {
            if (!m_isStarted)
            {
                return;
            }
            if (RuntimeEditorApplication.IsPlaymodeStateChanging)
            {
                return;
            }
            GameObject newParentGO         = null;
            GameObject oldParentGO         = null;
            bool       isNewParentExpanded = true;
            bool       isOldParentExpanded = true;
            bool       isLastChild         = false;

            if (newParent != null)
            {
                newParentGO         = newParent.gameObject;
                isNewParentExpanded = m_treeView.IsExpanded(newParentGO);
            }

            if (oldParent != null)
            {
                oldParentGO         = oldParent.gameObject;
                isLastChild         = (oldParent.ChildCount - oldParent.MarkedAsDestroyedChildCount) <= 1;
                isOldParentExpanded = m_treeView.IsExpanded(oldParentGO);
            }

            if (isNewParentExpanded)
            {
                m_treeView.ChangeParent(newParentGO, obj.gameObject);
                if (!isOldParentExpanded)
                {
                    if (isLastChild)
                    {
                        VirtualizingTreeViewItem oldParentContainer = m_treeView.GetTreeViewItem(oldParentGO);
                        if (oldParentContainer)
                        {
                            oldParentContainer.CanExpand = false;
                        }
                    }
                }
            }
            else
            {
                if (newParentGO != null)
                {
                    VirtualizingTreeViewItem newParentTreeViewItem = m_treeView.GetTreeViewItem(newParentGO);
                    if (newParentTreeViewItem != null)
                    {
                        newParentTreeViewItem.CanExpand = true;
                    }
                }

                m_treeView.RemoveChild(oldParentGO, obj.gameObject, isLastChild);
            }
        }
Пример #2
0
        private void OnParentChanged(ExposeToEditor obj, ExposeToEditor oldParent, ExposeToEditor newParent)
        {
            if (Editor.IsPlaymodeStateChanging)
            {
                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);
            }
        }
Пример #3
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);
            }
        }
Пример #4
0
 private void Expand(ProjectItem item)
 {
     if (item == null)
     {
         return;
     }
     if (item.Parent != null && !m_treeView.IsExpanded(item.Parent))
     {
         Expand(item.Parent);
     }
     m_treeView.Expand(item);
 }