示例#1
0
 public void ChangeParent(ProjectItem[] projectItems)
 {
     for (int i = 0; i < projectItems.Length; ++i)
     {
         m_treeView.ChangeParent(projectItems[i].Parent, projectItems[i]);
     }
 }
        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);
            }
        }
        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);
            }
        }
        private void Update()
        {
            if (Input.GetKeyDown(KeyCode.Space))
            {
                m_obj.SetParent(m_parent, true);
                m_treeView.ChangeParent(m_parent.gameObject, m_obj.gameObject);

                VirtualizingScrollRect scrollRect = m_treeView.GetComponentInChildren <VirtualizingScrollRect>();
                scrollRect.Index = m_treeView.IndexOf(m_parent.gameObject);
            }
        }
示例#5
0
        public void ChangeParent(ProjectItem projectItem, ProjectItem oldParent)
        {
            if (!m_treeView.IsDropInProgress && m_treeView.GetItemContainerData(projectItem) != null)
            {
                m_treeView.ChangeParent(projectItem.Parent, projectItem);
            }

            VirtualizingTreeViewItem tvOldParent = m_treeView.GetTreeViewItem(oldParent);
            if (tvOldParent != null)
            {
                tvOldParent.CanExpand = oldParent.Children != null && oldParent.Children.Any(c => c.IsFolder);
            }

            VirtualizingTreeViewItem tvNewParent = m_treeView.GetTreeViewItem(projectItem.Parent);
            if (tvNewParent != null)
            {
                tvNewParent.CanExpand = true;
            }
        }
示例#6
0
        public override void Drop(object[] dragObjects, PointerEventData pointerEventData)
        {
            base.Drop(dragObjects, pointerEventData);

            ProjectItem dropTarget = (ProjectItem)m_treeView.DropTarget;

            if (CanDrop(dropTarget, dragObjects))
            {
                for (int i = 0; i < dragObjects.Length; ++i)
                {
                    object      dragObject  = dragObjects[i];
                    ProjectItem projectItem = dragObject as ProjectItem;

                    dropTarget.AddChild(projectItem);
                    if (!(projectItem is AssetItem))
                    {
                        m_treeView.ChangeParent(dropTarget, projectItem);
                    }
                }
            }

            m_treeView.ExternalItemDrop();
        }