private void OnObjectAwaked(ExposeToEditor o)
        {
            if (o is ExposeToEditor)
            {
                if (m_isSpawningPrefab && m_treeView.DropAction != ItemDropAction.None)
                {
                    VirtualizingTreeViewItem treeViewItem = m_treeView.GetTreeViewItem(m_treeView.DropTarget);
                    GameObject dropTarget = (GameObject)m_treeView.DropTarget;
                    if (m_treeView.DropAction == ItemDropAction.SetLastChild)
                    {
                        o.transform.SetParent(dropTarget.transform);
                        if (m_treeView.IndexOf(o.gameObject) == -1)
                        {
                            m_treeView.AddChild(dropTarget, o.gameObject);
                        }
                        treeViewItem.CanExpand  = true;
                        treeViewItem.IsExpanded = true;
                    }
                    else
                    {
                        int index;
                        if (m_treeView.DropAction == ItemDropAction.SetNextSibling)
                        {
                            index = m_treeView.IndexOf(dropTarget) + 1;
                        }
                        else
                        {
                            index = m_treeView.IndexOf(dropTarget);
                        }

                        o.transform.SetParent(dropTarget.transform.parent);
                        o.transform.SetSiblingIndex(index);

                        TreeViewItemContainerData itemContainerData = (TreeViewItemContainerData)m_treeView.Insert(index, o.gameObject);
                        itemContainerData.Parent = treeViewItem.Parent;



                        //TreeViewItem newTreeViewItem = (TreeViewItem)m_treeView.Insert(index, o.gameObject);
                        //newTreeViewItem.Parent = treeViewItem.Parent;
                    }
                }
                else
                {
                    ExposeToEditor obj    = o;
                    GameObject     parent = null;

                    if (obj.Parent != null)
                    {
                        parent = obj.Parent.gameObject;
                    }
                    if (m_treeView.IndexOf(obj.gameObject) == -1)
                    {
                        m_treeView.AddChild(parent, obj.gameObject);
                    }
                }

                m_isSpawningPrefab = false;
            }
        }
Beispiel #2
0
 protected virtual void OnObjectAwaked(ExposeToEditor obj)
 {
     if (!m_isSpawningPrefab)
     {
         if (!obj.MarkAsDestroyed && m_treeView.IndexOf(obj) == -1)
         {
             ExposeToEditor parent = obj.GetParent();
             m_treeView.AddChild(parent, obj);
         }
     }
 }
Beispiel #3
0
        private void AddItem(ProjectItem parentFolder, ProjectItem folder, string[] existingNames)
        {
            m_treeView.AddChild(parentFolder, folder);

            if (existingNames.Length > 0)
            {
                int index = Array.IndexOf(existingNames.Union(new[] { folder.Name }).OrderBy(n => n).ToArray(), folder.Name);
                if (index > 0)
                {
                    m_treeView.SetNextSibling(parentFolder.Children.Where(c => c.IsFolder).OrderBy(c => c.Name).ElementAt(index - 1), folder);
                }
                else
                {
                    m_treeView.SetPrevSibling(parentFolder.Children.Where(c => c.IsFolder).OrderBy(c => c.Name).ElementAt(index + 1), folder);
                }
            }

            ProjectItem projectItem = parentFolder;

            Expand(parentFolder);
            m_treeView.ScrollIntoView(folder);
            m_treeView.SelectedItem = folder;

            VirtualizingTreeViewItem treeViewItem = m_treeView.GetTreeViewItem(folder);

            treeViewItem.IsEditing = true;
        }
        protected virtual void AddItem(ProjectItem parentFolder, ProjectItem folder, string[] existingNames, bool select, bool expand)
        {
            m_treeView.AddChild(parentFolder, folder);

            if (existingNames.Length > 0)
            {
                int index = Array.IndexOf(existingNames.Union(new[] { folder.Name }).OrderBy(n => n).ToArray(), folder.Name);
                if (index > 0)
                {
                    m_treeView.SetNextSibling(parentFolder.Children.Where(c => c.IsFolder).OrderBy(c => c.Name).ElementAt(index - 1), folder);
                }
                else
                {
                    m_treeView.SetPrevSibling(parentFolder.Children.Where(c => c.IsFolder).OrderBy(c => c.Name).ElementAt(index + 1), folder);
                }
            }

            if (expand)
            {
                ProjectItem projectItem = parentFolder;
                Expand(parentFolder);
            }

            if (select)
            {
                if (m_treeView.GetTreeViewItem(folder) != null)
                {
                    m_treeView.ScrollIntoView(folder);
                }
                m_treeView.SelectedItem = folder;
            }
        }
 public void AddProjectItem(ProjectItem item, ProjectItem parent)
 {
     m_treeView.AddChild(parent, item);
 }