Exemple #1
0
        public static void SetChildParentReferences(List <TreeViewItem> visibleItems, TreeViewItem root)
        {
            for (int i = 0; i < visibleItems.Count; i++)
            {
                visibleItems[i].parent = null;
            }
            int num = 0;

            for (int j = 0; j < visibleItems.Count; j++)
            {
                TreeViewUtility.SetChildParentReferences(j, visibleItems);
                if (visibleItems[j].parent == null)
                {
                    num++;
                }
            }
            if (num > 0)
            {
                List <TreeViewItem> list = new List <TreeViewItem>(num);
                for (int k = 0; k < visibleItems.Count; k++)
                {
                    if (visibleItems[k].parent == null)
                    {
                        list.Add(visibleItems[k]);
                        visibleItems[k].parent = root;
                    }
                }
                root.children = list;
            }
        }
Exemple #2
0
        private void ReadAssetDatabase(string assetFolderRootPath, TreeViewItem parent, int baseDepth)
        {
            // Read from Assets directory
            IHierarchyProperty property = new HierarchyProperty(assetFolderRootPath);

            property.Reset();

            Texture2D folderIcon      = EditorGUIUtility.FindTexture(EditorResources.folderIconName);
            Texture2D emptyFolderIcon = EditorGUIUtility.FindTexture(EditorResources.emptyFolderIconName);

            List <TreeViewItem> allFolders = new List <TreeViewItem>();

            while (property.Next(null))
            {
                if (property.isFolder)
                {
                    TreeViewItem folderItem = new TreeViewItem(property.instanceID, baseDepth + property.depth, null, property.name);
                    folderItem.icon = property.hasChildren ? folderIcon : emptyFolderIcon;
                    allFolders.Add(folderItem);
                }
            }

            // Fix references
            TreeViewUtility.SetChildParentReferences(allFolders, parent);
        }
Exemple #3
0
        private TreeViewItem BuildTreeView()
        {
            this.Init();
            if (this.m_SavedFilters.Count == 0)
            {
                Debug.LogError((object)"BuildTreeView: No saved filters! We should at least have a root");
                return((TreeViewItem)null);
            }
            TreeViewItem        root         = (TreeViewItem)null;
            List <TreeViewItem> visibleItems = new List <TreeViewItem>();

            for (int index = 0; index < this.m_SavedFilters.Count; ++index)
            {
                SavedFilter  savedFilter  = this.m_SavedFilters[index];
                int          id           = savedFilter.m_ID;
                int          depth        = savedFilter.m_Depth;
                bool         isFolder     = savedFilter.m_Filter.GetState() == SearchFilter.State.FolderBrowsing;
                TreeViewItem treeViewItem = (TreeViewItem) new SearchFilterTreeItem(id, depth, (TreeViewItem)null, savedFilter.m_Name, isFolder);
                if (index == 0)
                {
                    root = treeViewItem;
                }
                else
                {
                    visibleItems.Add(treeViewItem);
                }
            }
            TreeViewUtility.SetChildParentReferences(visibleItems, root);
            return(root);
        }
Exemple #4
0
        private TreeViewItem BuildTreeView()
        {
            this.Init();
            if (this.m_SavedFilters.Count == 0)
            {
                Debug.LogError("BuildTreeView: No saved filters! We should at least have a root");
                return(null);
            }
            TreeViewItem        root         = null;
            List <TreeViewItem> visibleItems = new List <TreeViewItem>();

            for (int i = 0; i < this.m_SavedFilters.Count; i++)
            {
                SavedFilter  filter   = this.m_SavedFilters[i];
                int          iD       = filter.m_ID;
                int          depth    = filter.m_Depth;
                bool         isFolder = filter.m_Filter.GetState() == SearchFilter.State.FolderBrowsing;
                TreeViewItem item     = new SearchFilterTreeItem(iD, depth, null, filter.m_Name, isFolder);
                if (i == 0)
                {
                    root = item;
                }
                else
                {
                    visibleItems.Add(item);
                }
            }
            TreeViewUtility.SetChildParentReferences(visibleItems, root);
            return(root);
        }
        private TreeViewItem BuildTreeView()
        {
            this.Init();
            TreeViewItem result;

            if (this.m_SavedFilters.Count == 0)
            {
                Debug.LogError("BuildTreeView: No saved filters! We should at least have a root");
                result = null;
            }
            else
            {
                TreeViewItem        treeViewItem = null;
                List <TreeViewItem> list         = new List <TreeViewItem>();
                for (int i = 0; i < this.m_SavedFilters.Count; i++)
                {
                    SavedFilter  savedFilter   = this.m_SavedFilters[i];
                    int          iD            = savedFilter.m_ID;
                    int          depth         = savedFilter.m_Depth;
                    bool         isFolder      = savedFilter.m_Filter.GetState() == SearchFilter.State.FolderBrowsing;
                    TreeViewItem treeViewItem2 = new SearchFilterTreeItem(iD, depth, null, savedFilter.m_Name, isFolder);
                    if (i == 0)
                    {
                        treeViewItem = treeViewItem2;
                    }
                    else
                    {
                        list.Add(treeViewItem2);
                    }
                }
                TreeViewUtility.SetChildParentReferences(list, treeViewItem);
                result = treeViewItem;
            }
            return(result);
        }
Exemple #6
0
 public override void FetchData()
 {
   this.m_RootItem = new TreeViewItem(this.m_RootInstanceID, 0, (TreeViewItem) null, AssetsTreeViewDataSource.CreateDisplayName(this.m_RootInstanceID));
   if (!this.showRootNode)
     this.SetExpanded(this.m_RootItem, true);
   IHierarchyProperty hierarchyProperty = (IHierarchyProperty) new HierarchyProperty(HierarchyType.Assets);
   hierarchyProperty.Reset();
   if (!hierarchyProperty.Find(this.m_RootInstanceID, (int[]) null))
     Debug.LogError((object) ("Root Asset with id " + (object) this.m_RootInstanceID + " not found!!"));
   int minDepth = hierarchyProperty.depth + (!this.showRootNode ? 1 : 0);
   int[] array = this.expandedIDs.ToArray();
   Texture2D texture = EditorGUIUtility.FindTexture(EditorResourcesUtility.emptyFolderIconName);
   this.m_VisibleRows = new List<TreeViewItem>();
   while (hierarchyProperty.NextWithDepthCheck(array, minDepth))
   {
     if (!this.foldersOnly || hierarchyProperty.isFolder)
     {
       int depth = hierarchyProperty.depth - minDepth;
       TreeViewItem treeViewItem = !hierarchyProperty.isFolder ? (TreeViewItem) new AssetsTreeViewDataSource.NonFolderTreeItem(hierarchyProperty.instanceID, depth, (TreeViewItem) null, hierarchyProperty.name) : (TreeViewItem) new AssetsTreeViewDataSource.FolderTreeItem(hierarchyProperty.instanceID, depth, (TreeViewItem) null, hierarchyProperty.name);
       treeViewItem.icon = !hierarchyProperty.isFolder || hierarchyProperty.hasChildren ? hierarchyProperty.icon : texture;
       if (hierarchyProperty.hasChildren)
         treeViewItem.AddChild((TreeViewItem) null);
       this.m_VisibleRows.Add(treeViewItem);
     }
   }
   TreeViewUtility.SetChildParentReferences(this.m_VisibleRows, this.m_RootItem);
   if (this.foldersFirst)
   {
     AssetsTreeViewDataSource.FoldersFirstRecursive(this.m_RootItem);
     this.m_VisibleRows.Clear();
     this.GetVisibleItemsRecursive(this.m_RootItem, this.m_VisibleRows);
   }
   this.m_NeedRefreshVisibleFolders = false;
   this.m_TreeView.SetSelection(Selection.instanceIDs, false);
 }
Exemple #7
0
        public static void SetChildParentReferences(List <TreeViewItem> visibleItems, TreeViewItem root)
        {
            for (int index = 0; index < visibleItems.Count; ++index)
            {
                visibleItems[index].parent = (TreeViewItem)null;
            }
            int capacity = 0;

            for (int parentIndex = 0; parentIndex < visibleItems.Count; ++parentIndex)
            {
                TreeViewUtility.SetChildParentReferences(parentIndex, visibleItems);
                if (visibleItems[parentIndex].parent == null)
                {
                    ++capacity;
                }
            }
            if (capacity <= 0)
            {
                return;
            }
            List <TreeViewItem> treeViewItemList = new List <TreeViewItem>(capacity);

            for (int index = 0; index < visibleItems.Count; ++index)
            {
                if (visibleItems[index].parent == null)
                {
                    treeViewItemList.Add(visibleItems[index]);
                    visibleItems[index].parent = root;
                }
            }
            root.children = treeViewItemList;
        }
Exemple #8
0
 private static TreeViewItem FindItemRecursive(int id, TreeViewItem item)
 {
     if (item == null)
     {
         return((TreeViewItem)null);
     }
     if (item.id == id)
     {
         return(item);
     }
     if (!item.hasChildren)
     {
         return((TreeViewItem)null);
     }
     using (List <TreeViewItem> .Enumerator enumerator = item.children.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             TreeViewItem current       = enumerator.Current;
             TreeViewItem itemRecursive = TreeViewUtility.FindItemRecursive(id, current);
             if (itemRecursive != null)
             {
                 return(itemRecursive);
             }
         }
     }
     return((TreeViewItem)null);
 }
            private TreeViewItem EnsureFolderPath(string folderPath, Dictionary <string, PackageImportTreeView.PackageImportTreeViewItem> treeViewFolders, bool initExpandedState)
            {
                TreeViewItem result;

                if (folderPath == "")
                {
                    result = this.m_RootItem;
                }
                else
                {
                    int          hashCode     = folderPath.GetHashCode();
                    TreeViewItem treeViewItem = TreeViewUtility.FindItem(hashCode, this.m_RootItem);
                    if (treeViewItem != null)
                    {
                        result = treeViewItem;
                    }
                    else
                    {
                        string[] array = folderPath.Split(new char[]
                        {
                            '/'
                        });
                        string       text          = "";
                        TreeViewItem treeViewItem2 = this.m_RootItem;
                        int          num           = -1;
                        for (int i = 0; i < array.Length; i++)
                        {
                            string text2 = array[i];
                            if (text != "")
                            {
                                text += '/';
                            }
                            text += text2;
                            if (i != 0 || !(text == "Assets"))
                            {
                                num++;
                                hashCode = text.GetHashCode();
                                PackageImportTreeView.PackageImportTreeViewItem packageImportTreeViewItem;
                                if (treeViewFolders.TryGetValue(text, out packageImportTreeViewItem))
                                {
                                    treeViewItem2 = packageImportTreeViewItem;
                                }
                                else
                                {
                                    PackageImportTreeView.PackageImportTreeViewItem packageImportTreeViewItem2 = new PackageImportTreeView.PackageImportTreeViewItem(null, hashCode, num, treeViewItem2, text2);
                                    treeViewItem2.AddChild(packageImportTreeViewItem2);
                                    treeViewItem2 = packageImportTreeViewItem2;
                                    if (initExpandedState)
                                    {
                                        this.m_TreeView.state.expandedIDs.Add(hashCode);
                                    }
                                    treeViewFolders[text] = packageImportTreeViewItem2;
                                }
                            }
                        }
                        result = treeViewItem2;
                    }
                }
                return(result);
            }
Exemple #10
0
        // Utility function for building a tree view from saved filter state. Returns root of tree
        TreeViewItem BuildTreeView()
        {
            Init();

            if (m_SavedFilters.Count == 0)
            {
                Debug.LogError("BuildTreeView: No saved filters! We should at least have a root");
                return(null);
            }

            TreeViewItem root = null;

            // Create rest of nodes
            List <TreeViewItem> items = new List <TreeViewItem>();

            for (int i = 0; i < m_SavedFilters.Count; ++i)
            {
                SavedFilter  savedFilter = m_SavedFilters[i];
                int          instanceID  = savedFilter.m_ID;
                int          depth       = savedFilter.m_Depth;
                bool         isFolder    = savedFilter.m_Filter.GetState() == SearchFilter.State.FolderBrowsing;
                TreeViewItem item        = new SearchFilterTreeItem(instanceID, depth, null, savedFilter.m_Name, isFolder);
                if (i == 0)
                {
                    root = item;
                }
                else
                {
                    if (Collab.instance.collabFilters.ContainsSearchFilter(savedFilter.m_Name, savedFilter.m_Filter.FilterToSearchFieldString()))
                    {
                        if (!Collab.instance.IsCollabEnabledForCurrentProject())
                        {
                            continue;
                        }
                    }

                    if (SoftlockViewController.Instance.softLockFilters.ContainsSearchFilter(savedFilter.m_Name, savedFilter.m_Filter.FilterToSearchFieldString()))
                    {
                        if (CollabSettingsManager.IsAvailable(CollabSettingType.InProgressEnabled))
                        {
                            if (!Collab.instance.IsCollabEnabledForCurrentProject() || !CollabSettingsManager.inProgressEnabled)
                            {
                                continue;
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }
                    items.Add(item);
                }
            }

            // Fix child/parent references
            TreeViewUtility.SetChildParentReferences(items, root);

            return(root);
        }
 internal void SetupChildParentReferencesIfNeeded()
 {
     if (this.m_NeedsChildParentReferenceSetup)
     {
         this.m_NeedsChildParentReferenceSetup = false;
         TreeViewUtility.SetChildParentReferences(this.GetRows(), this.m_RootItem);
     }
 }
Exemple #12
0
        private TreeViewItem BuildTreeView()
        {
            this.Init();
            TreeViewItem result;

            if (this.m_SavedFilters.Count == 0)
            {
                Debug.LogError("BuildTreeView: No saved filters! We should at least have a root");
                result = null;
            }
            else
            {
                TreeViewItem        treeViewItem = null;
                List <TreeViewItem> list         = new List <TreeViewItem>();
                int i = 0;
                while (i < this.m_SavedFilters.Count)
                {
                    SavedFilter  savedFilter   = this.m_SavedFilters[i];
                    int          iD            = savedFilter.m_ID;
                    int          depth         = savedFilter.m_Depth;
                    bool         isFolder      = savedFilter.m_Filter.GetState() == SearchFilter.State.FolderBrowsing;
                    TreeViewItem treeViewItem2 = new SearchFilterTreeItem(iD, depth, null, savedFilter.m_Name, isFolder);
                    if (i == 0)
                    {
                        treeViewItem = treeViewItem2;
                    }
                    else
                    {
                        if (Collab.instance.collabFilters.ContainsSearchFilter(savedFilter.m_Name, savedFilter.m_Filter.FilterToSearchFieldString()))
                        {
                            if (!Collab.instance.IsCollabEnabledForCurrentProject())
                            {
                                goto IL_133;
                            }
                        }
                        if (SoftlockViewController.Instance.softLockFilters.ContainsSearchFilter(savedFilter.m_Name, savedFilter.m_Filter.FilterToSearchFieldString()))
                        {
                            if (!CollabSettingsManager.IsAvailable(CollabSettingType.InProgressEnabled))
                            {
                                goto IL_133;
                            }
                            if (!Collab.instance.IsCollabEnabledForCurrentProject() || !CollabSettingsManager.inProgressEnabled)
                            {
                                goto IL_133;
                            }
                        }
                        list.Add(treeViewItem2);
                    }
IL_133:
                    i++;
                    continue;
                    goto IL_133;
                }
                TreeViewUtility.SetChildParentReferences(list, treeViewItem);
                result = treeViewItem;
            }
            return(result);
        }
 internal void SetupChildParentReferencesIfNeeded()
 {
     this.EnsureFullyInitialized();
     if (this.m_NeedsChildParentReferenceSetup)
     {
         this.m_NeedsChildParentReferenceSetup = false;
         TreeViewUtility.SetChildParentReferences(this.GetRows(), base.m_RootItem);
     }
 }
        SerializedNodeInfo FillNodeInfos()
        {
            var rootNode = new SerializedNodeInfo()
            {
                depth = -1, displayName = "", id = 0, children = new List <TreeViewItem>(0)
            };

            if (m_TransformPaths == null || m_TransformPaths.Length < 1)
            {
                return(rootNode);
            }

            var            nodesCount  = m_TransformPaths.Length;
            var            nodeInfos   = new List <SerializedNodeInfo>(nodesCount - 1);
            Stack <string> depth       = new Stack <string>(nodesCount);
            string         currentPath = String.Empty;

            // skip the first index as it is the empty root of the gameObject
            for (int i = 1; i < nodesCount; i++)
            {
                var newNode = new SerializedNodeInfo();
                newNode.id           = i;
                newNode.path         = m_TransformPaths[i];
                newNode.getNodeState = GetNodeState;
                newNode.setNodeState = SetNodeState;

                var newPath = newNode.path;
                while (!string.IsNullOrEmpty(currentPath) && !newPath.StartsWith(currentPath + "/", StringComparison.InvariantCulture))
                {
                    // we are in a new node, lets unstack until we reach the correct hierarchy
                    var oldParent = depth.Pop();
                    var index     = currentPath.LastIndexOf(oldParent, StringComparison.InvariantCulture);
                    if (index > 0)
                    {
                        index--;
                    }
                    currentPath = currentPath.Remove(index);
                }
                var nodeName = newPath;
                if (!string.IsNullOrEmpty(currentPath))
                {
                    nodeName = nodeName.Remove(0, currentPath.Length + 1);
                }

                newNode.depth       = depth.Count;
                newNode.displayName = nodeName;

                depth.Push(nodeName);
                currentPath = newPath;

                nodeInfos.Add(newNode);
            }

            TreeViewUtility.SetChildParentReferences(nodeInfos.Cast <TreeViewItem>().ToList(), rootNode);
            return(rootNode);
        }
 public void CullNonExistingItemsFromSelection()
 {
     for (int i = state.selectedIDs.Count - 1; i >= 0; i--)
     {
         if (TreeViewUtility.FindItem(state.selectedIDs[i], rootItem) == null)
         {
             state.selectedIDs.RemoveAt(i);
         }
     }
 }
Exemple #16
0
        // this gets called whenever someone issues a reload() call to the parent
        protected override IList <TreeViewItem> BuildRows(TreeViewItem root)
        {
            if (m_Items == null)
            {
                var rawData = m_DataStore.GetElements();
                m_Items = new List <TreeViewItem>(rawData.Length);

                for (int i = 0; i < rawData.Length; i++)
                {
                    var item = new SerializedPropertyItem(rawData[i].objectId, 0, rawData[i]);
                    m_Items.Add(item);
                }
            }

            // filtering
            IEnumerable <TreeViewItem> tmprows = m_Items;

            if (!m_ShowInactiveObjects && m_ShowFilterGUI)
            {
                tmprows = m_Items.Where((TreeViewItem item) => { return(((SerializedPropertyItem)item).GetData().activeInHierarchy); });
            }

            if (m_bFilterSelection && m_ShowFilterGUI)
            {
                if (m_SelectionFilter == null)
                {
                    m_SelectionFilter = Selection.instanceIDs;
                }
                tmprows = m_Items.Where((TreeViewItem item) => { return(m_SelectionFilter.Contains(item.id)); });
            }
            else
            {
                m_SelectionFilter = null;
            }

            tmprows = Filter(tmprows);

            var rows = tmprows.ToList();

            if (multiColumnHeader.sortedColumnIndex >= 0)
            {
                Sort(rows, multiColumnHeader.sortedColumnIndex);
            }

            m_ChangedId = 0;

            // We still need to setup the child parent information for the rows since this
            // information is used by the TreeView internal logic (navigation, dragging etc)
            TreeViewUtility.SetParentAndChildrenForItems(rows, root);

            return(rows);
        }
Exemple #17
0
        internal void SetupChildParentReferencesIfNeeded()
        {
            // Ensure all rows are initialized (not only the visible)
            EnsureFullyInitialized();

            // We delay the calling SetChildParentReferences until needed to ensure fast reloading of
            // the game object hierarchy (in playmode this prevent hiccups for large scenes)
            if (m_NeedsChildParentReferenceSetup)
            {
                m_NeedsChildParentReferenceSetup = false;
                TreeViewUtility.SetChildParentReferences(GetRows(), m_RootItem);
            }
        }
            private TreeViewItem EnsureFolderPath(string folderPath, Dictionary <string, PackageExportTreeView.PackageExportTreeViewItem> treeViewFolders, bool initExpandedState)
            {
                if (folderPath == "")
                {
                    return(base.m_RootItem);
                }
                TreeViewItem item2 = TreeViewUtility.FindItem(folderPath.GetHashCode(), base.m_RootItem);

                if (item2 != null)
                {
                    return(item2);
                }
                char[]       separator = new char[] { '/' };
                string[]     strArray  = folderPath.Split(separator);
                string       key       = "";
                TreeViewItem rootItem  = base.m_RootItem;
                int          depth     = -1;

                for (int i = 0; i < strArray.Length; i++)
                {
                    string displayName = strArray[i];
                    if (key != "")
                    {
                        key = key + '/';
                    }
                    key = key + displayName;
                    if ((i != 0) || (key != "Assets"))
                    {
                        PackageExportTreeView.PackageExportTreeViewItem item4;
                        depth++;
                        int hashCode = key.GetHashCode();
                        if (treeViewFolders.TryGetValue(key, out item4))
                        {
                            rootItem = item4;
                        }
                        else
                        {
                            PackageExportTreeView.PackageExportTreeViewItem child = new PackageExportTreeView.PackageExportTreeViewItem(null, hashCode, depth, rootItem, displayName);
                            rootItem.AddChild(child);
                            rootItem = child;
                            if (initExpandedState)
                            {
                                base.m_TreeView.state.expandedIDs.Add(hashCode);
                            }
                            treeViewFolders[key] = child;
                        }
                    }
                }
                return(rootItem);
            }
Exemple #19
0
            private TreeViewItem EnsureFolderPath(string folderPath, Dictionary <string, PackageExportTreeView.PackageExportTreeViewItem> treeViewFolders, bool initExpandedState)
            {
                if (folderPath == string.Empty)
                {
                    return(this.m_RootItem);
                }
                TreeViewItem treeViewItem = TreeViewUtility.FindItem(folderPath.GetHashCode(), this.m_RootItem);

                if (treeViewItem != null)
                {
                    return(treeViewItem);
                }
                string[]     strArray = folderPath.Split('/');
                string       empty    = string.Empty;
                TreeViewItem parent   = this.m_RootItem;
                int          depth    = -1;

                for (int index = 0; index < strArray.Length; ++index)
                {
                    string displayName = strArray[index];
                    if (empty != string.Empty)
                    {
                        empty += (string)(object)'/';
                    }
                    empty += displayName;
                    if (index != 0 || !(empty == "Assets"))
                    {
                        ++depth;
                        int hashCode = empty.GetHashCode();
                        PackageExportTreeView.PackageExportTreeViewItem exportTreeViewItem1;
                        if (treeViewFolders.TryGetValue(empty, out exportTreeViewItem1))
                        {
                            parent = (TreeViewItem)exportTreeViewItem1;
                        }
                        else
                        {
                            PackageExportTreeView.PackageExportTreeViewItem exportTreeViewItem2 = new PackageExportTreeView.PackageExportTreeViewItem((ExportPackageItem)null, hashCode, depth, parent, displayName);
                            parent.AddChild((TreeViewItem)exportTreeViewItem2);
                            parent = (TreeViewItem)exportTreeViewItem2;
                            if (initExpandedState)
                            {
                                this.m_TreeView.state.expandedIDs.Add(hashCode);
                            }
                            treeViewFolders[empty] = exportTreeViewItem2;
                        }
                    }
                }
                return(parent);
            }
        private void ReadAssetDatabase(string assetFolderRootPath, TreeViewItem parent, int baseDepth, IList <TreeViewItem> allRows)
        {
            // Read from Assets directory
            IHierarchyProperty property = new HierarchyProperty(assetFolderRootPath);

            property.Reset();

            if (!IsExpanded(parent))
            {
                if (HasSubFolders(property))
                {
                    parent.children = CreateChildListForCollapsedParent();
                }
                return;
            }

            Texture2D folderIcon = EditorGUIUtility.FindTexture(EditorResources.folderIconName);

            List <TreeViewItem> allFolders = new List <TreeViewItem>();
            var expandedIDs = m_TreeView.state.expandedIDs.ToArray();

            while (property.Next(expandedIDs))
            {
                if (property.isFolder)
                {
                    AssetsTreeViewDataSource.FolderTreeItem folderItem = new AssetsTreeViewDataSource.FolderTreeItem(property.guid, !property.hasChildren, property.GetInstanceIDIfImported(), baseDepth + property.depth, null, property.name);
                    folderItem.icon = folderIcon;
                    allFolders.Add(folderItem);
                    allRows.Add(folderItem);
                    if (!IsExpanded(folderItem))
                    {
                        if (HasSubFolders(property))
                        {
                            folderItem.children = CreateChildListForCollapsedParent();
                        }
                    }
                    else // expanded status does not get updated when deleting/moving folders. We need to check if the expanded folder still has subFolders when reading the AssetDatabase
                    {
                        if (!HasSubFolders(property))
                        {
                            SetExpanded(folderItem, false);
                        }
                    }
                }
            }

            // Fix references
            TreeViewUtility.SetChildParentReferences(allFolders, parent);
        }
 private void SetChildParentOfMixerItem(AudioMixerItem item, List <AudioMixerItem> items)
 {
     if (item.mixer.outputAudioMixerGroup != null)
     {
         AudioMixerItem item2 = TreeViewUtility.FindItemInList <AudioMixerItem>(item.mixer.outputAudioMixerGroup.audioMixer.GetInstanceID(), items) as AudioMixerItem;
         if (item2 != null)
         {
             item2.AddChild(item);
         }
     }
     else
     {
         base.m_RootItem.AddChild(item);
     }
 }
        public void CullNonExistingItemsFromSelection()
        {
            for (int i = state.selectedIDs.Count - 1; i >= 0; i--)
            {
                if (TreeViewUtility.FindItem(state.selectedIDs[i], rootItem) == null)
                {
                    state.selectedIDs.RemoveAt(i);
                }
            }

            if (state.selectedIDs.Count != 1 && PopupWindowWithoutFocus.IsVisible())
            {
                PopupWindowWithoutFocus.Hide();
            }
        }
Exemple #23
0
 public static void DebugPrintToEditorLogRecursive(TreeViewItem item)
 {
     if (item == null)
     {
         return;
     }
     Console.WriteLine(new string(' ', item.depth * 3) + item.displayName);
     if (!item.hasChildren)
     {
         return;
     }
     foreach (TreeViewItem current in item.children)
     {
         TreeViewUtility.DebugPrintToEditorLogRecursive(current);
     }
 }
 void SetChildParentOfMixerItem(AudioMixerItem item, List <AudioMixerItem> items)
 {
     if (item.mixer.outputAudioMixerGroup != null)
     {
         var parentMixer = item.mixer.outputAudioMixerGroup.audioMixer;
         var parentItem  = TreeViewUtility.FindItemInList(parentMixer.GetInstanceID(), items) as AudioMixerItem;
         if (parentItem != null)
         {
             parentItem.AddChild(item);
         }
     }
     else
     {
         m_RootItem.AddChild(item);
     }
 }
 private void SetChildParentOfMixerItem(AudioMixerItem item, List <AudioMixerItem> items)
 {
     if ((UnityEngine.Object)item.mixer.outputAudioMixerGroup != (UnityEngine.Object)null)
     {
         AudioMixerItem itemInList = TreeViewUtility.FindItemInList <AudioMixerItem>(item.mixer.outputAudioMixerGroup.audioMixer.GetInstanceID(), items) as AudioMixerItem;
         if (itemInList == null)
         {
             return;
         }
         itemInList.AddChild((TreeViewItem)item);
     }
     else
     {
         this.m_RootItem.AddChild((TreeViewItem)item);
     }
 }
Exemple #26
0
        private static void SetChildParentReferences(int parentIndex, List <TreeViewItem> visibleItems)
        {
            TreeViewItem treeViewItem = visibleItems[parentIndex];
            bool         flag         = treeViewItem.children != null && treeViewItem.children.Count > 0 && treeViewItem.children[0] != null;

            if (flag)
            {
                return;
            }
            int depth = treeViewItem.depth;
            int num   = 0;

            for (int i = parentIndex + 1; i < visibleItems.Count; i++)
            {
                if (visibleItems[i].depth == depth + 1)
                {
                    num++;
                }
                if (visibleItems[i].depth <= depth)
                {
                    break;
                }
            }
            List <TreeViewItem> list = null;

            if (num != 0)
            {
                list = new List <TreeViewItem>(num);
                num  = 0;
                for (int j = parentIndex + 1; j < visibleItems.Count; j++)
                {
                    if (visibleItems[j].depth == depth + 1)
                    {
                        visibleItems[j].parent = treeViewItem;
                        list.Add(visibleItems[j]);
                        num++;
                    }
                    if (visibleItems[j].depth <= depth)
                    {
                        break;
                    }
                }
            }
            TreeViewUtility.SetChildren(treeViewItem, list);
        }
Exemple #27
0
        private static void SetChildParentReferences(int parentIndex, List <TreeViewItem> visibleItems)
        {
            TreeViewItem visibleItem = visibleItems[parentIndex];

            if (visibleItem.children != null && visibleItem.children.Count > 0 && visibleItem.children[0] != null)
            {
                return;
            }
            int depth    = visibleItem.depth;
            int capacity = 0;

            for (int index = parentIndex + 1; index < visibleItems.Count; ++index)
            {
                if (visibleItems[index].depth == depth + 1)
                {
                    ++capacity;
                }
                if (visibleItems[index].depth <= depth)
                {
                    break;
                }
            }
            List <TreeViewItem> newChildList = (List <TreeViewItem>)null;

            if (capacity != 0)
            {
                newChildList = new List <TreeViewItem>(capacity);
                int num = 0;
                for (int index = parentIndex + 1; index < visibleItems.Count; ++index)
                {
                    if (visibleItems[index].depth == depth + 1)
                    {
                        visibleItems[index].parent = visibleItem;
                        newChildList.Add(visibleItems[index]);
                        ++num;
                    }
                    if (visibleItems[index].depth <= depth)
                    {
                        break;
                    }
                }
            }
            TreeViewUtility.SetChildren(visibleItem, newChildList);
        }
 private void ReadAssetDatabase(TreeViewItem parent, int baseDepth)
 {
     IHierarchyProperty property = new HierarchyProperty(HierarchyType.Assets);
     property.Reset();
     Texture2D textured = EditorGUIUtility.FindTexture(EditorResourcesUtility.folderIconName);
     Texture2D textured2 = EditorGUIUtility.FindTexture(EditorResourcesUtility.emptyFolderIconName);
     List<TreeViewItem> visibleItems = new List<TreeViewItem>();
     while (property.Next(null))
     {
         if (property.isFolder)
         {
             TreeViewItem item = new TreeViewItem(property.instanceID, baseDepth + property.depth, null, property.name) {
                 icon = !property.hasChildren ? textured2 : textured
             };
             visibleItems.Add(item);
         }
     }
     TreeViewUtility.SetChildParentReferences(visibleItems, parent);
 }
Exemple #29
0
 public static void DebugPrintToEditorLogRecursive(TreeViewItem item)
 {
     if (item == null)
     {
         return;
     }
     Console.WriteLine(new string(' ', item.depth * 3) + item.displayName);
     if (!item.hasChildren)
     {
         return;
     }
     using (List <TreeViewItem> .Enumerator enumerator = item.children.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             TreeViewUtility.DebugPrintToEditorLogRecursive(enumerator.Current);
         }
     }
 }
        private void ReadAssetDatabase(TreeViewItem parent, int baseDepth)
        {
            IHierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.Assets);

            hierarchyProperty.Reset();
            Texture2D           texture2D  = EditorGUIUtility.FindTexture(EditorResourcesUtility.folderIconName);
            Texture2D           texture2D2 = EditorGUIUtility.FindTexture(EditorResourcesUtility.emptyFolderIconName);
            List <TreeViewItem> list       = new List <TreeViewItem>();

            while (hierarchyProperty.Next(null))
            {
                if (hierarchyProperty.isFolder)
                {
                    list.Add(new TreeViewItem(hierarchyProperty.instanceID, baseDepth + hierarchyProperty.depth, null, hierarchyProperty.name)
                    {
                        icon = (!hierarchyProperty.hasChildren) ? texture2D2 : texture2D
                    });
                }
            }
            TreeViewUtility.SetChildParentReferences(list, parent);
        }