private void InsertOrdered(ProjectItem parent, ProjectItem item)
        {
            parent.AddChild(item);

            m_treeView.RemoveChild(parent, item, parent.Children.Count == 1);

            VirtualizingTreeViewItem treeViewItem = m_treeView.GetTreeViewItem(item);

            if (treeViewItem == null)
            {
                m_treeView.AddChild(parent, item);
            }

            ProjectItem[] orderedChildren = parent.Children.OrderBy(projectItem => projectItem.NameExt).ToArray();
            int           index           = Array.IndexOf(orderedChildren, item);

            item.SetSiblingIndex(index);

            if (item.IsFolder)
            {
                if (index > 0)
                {
                    object prevSibling = parent.Children[index - 1];
                    m_treeView.SetNextSibling(prevSibling, item);
                }
                else
                {
                    if (parent.Children.Count > 1)
                    {
                        object nextSibling = parent.Children[1];
                        m_treeView.SetPrevSibling(nextSibling, item);
                    }
                }
            }
        }
Beispiel #2
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;
        }
        private void OnObjectMarkAsDestroyedChanged(ExposeToEditor o)
        {
            if (o.MarkAsDestroyed)
            {
                GameObject parent      = null;
                bool       isLastChild = false;
                if (o.Parent != null)
                {
                    parent      = o.Parent.gameObject;
                    isLastChild = (o.Parent.ChildCount - o.Parent.MarkedAsDestroyedChildCount) <= 0;
                }

                m_treeView.RemoveChild(parent, o.gameObject, isLastChild);
            }
            else
            {
                GameObject parent = null;

                if (o.Parent != null)
                {
                    parent = o.Parent.gameObject;
                }

                ExposeToEditor nextSibling = o.NextSibling();

                m_treeView.AddChild(parent, o.gameObject); //TODO: replace with Insert

                if (nextSibling != null)
                {
                    m_treeView.SetPrevSibling(nextSibling.gameObject, o.gameObject);
                }
            }
        }
        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;
            }
        }
        private void AddSortedByName(ExposeToEditor obj)
        {
            string[]       names = m_treeView.Items.OfType <ExposeToEditor>().Select(go => go.name).Union(new[] { obj.name }).OrderBy(k => k).ToArray();
            int            index = System.Array.IndexOf(names, obj.name);
            ExposeToEditor sibling;

            if (index == 0)
            {
                sibling = m_treeView.Items.OfType <ExposeToEditor>().FirstOrDefault();
                m_treeView.Add(obj);
                if (sibling != null)
                {
                    m_treeView.SetPrevSibling(sibling, obj);
                }
            }
            else
            {
                sibling = m_treeView.Items.OfType <ExposeToEditor>().ElementAt(index - 1);
                m_treeView.Add(obj);
                m_treeView.SetNextSibling(sibling, obj);
            }
        }
Beispiel #6
0
        protected virtual void SetSiblingIndex(ExposeToEditor o)
        {
            if (o.transform.parent == null && m_rootGameObjects == null)
            {
                m_rootGameObjects = SceneManager.GetActiveScene().GetRootGameObjects().OrderBy(g => g.transform.GetSiblingIndex()).ToList();
            }

            ExposeToEditor nextSibling = o.NextSibling(m_rootGameObjects);

            if (nextSibling != null)
            {
                m_treeView.SetPrevSibling(nextSibling, o);
            }
        }