private TreeViewItem EnsureFolderPath(string folderPath, Dictionary <string, PackageExportTreeView.PackageExportTreeViewItem> treeViewFolders, bool initExpandedState)
            {
                if (folderPath == string.Empty)
                {
                    return(this.m_RootItem);
                }
                int          hashCode     = folderPath.GetHashCode();
                TreeViewItem treeViewItem = TreeViewUtility.FindItem(hashCode, this.m_RootItem);

                if (treeViewItem != null)
                {
                    return(treeViewItem);
                }
                string[] array = folderPath.Split(new char[]
                {
                    '/'
                });
                string       text          = string.Empty;
                TreeViewItem treeViewItem2 = this.m_RootItem;
                int          num           = -1;

                for (int i = 0; i < array.Length; i++)
                {
                    string text2 = array[i];
                    if (text != string.Empty)
                    {
                        text += '/';
                    }
                    text += text2;
                    if (i != 0 || !(text == "Assets"))
                    {
                        num++;
                        hashCode = text.GetHashCode();
                        PackageExportTreeView.PackageExportTreeViewItem packageExportTreeViewItem;
                        if (treeViewFolders.TryGetValue(text, out packageExportTreeViewItem))
                        {
                            treeViewItem2 = packageExportTreeViewItem;
                        }
                        else
                        {
                            PackageExportTreeView.PackageExportTreeViewItem packageExportTreeViewItem2 = new PackageExportTreeView.PackageExportTreeViewItem(null, hashCode, num, treeViewItem2, text2);
                            treeViewItem2.AddChild(packageExportTreeViewItem2);
                            treeViewItem2 = packageExportTreeViewItem2;
                            if (initExpandedState)
                            {
                                this.m_TreeView.state.expandedIDs.Add(hashCode);
                            }
                            treeViewFolders[text] = packageExportTreeViewItem2;
                        }
                    }
                }
                return(treeViewItem2);
            }
            public override void FetchData()
            {
                this.m_RootItem = new PackageImportTreeView.PackageImportTreeViewItem("Assets".GetHashCode(), 0, null, "InvisibleAssetsFolder");
                ((PackageImportTreeView.PackageImportTreeViewItem) this.m_RootItem).isFolder = true;
                bool flag = this.m_TreeView.state.expandedIDs.Count == 0;

                if (flag)
                {
                    this.m_TreeView.state.expandedIDs.Add(this.m_RootItem.id);
                }
                Dictionary <string, AssetsItem> dictionary = new Dictionary <string, AssetsItem>();

                AssetsItem[] assetItems = this.m_AssetItems;
                for (int i = 0; i < assetItems.Length; i++)
                {
                    AssetsItem assetsItem = assetItems[i];
                    if (assetsItem.assetIsDir == 1)
                    {
                        dictionary[assetsItem.pathName] = assetsItem;
                    }
                }
                Dictionary <string, PackageImportTreeView.PackageImportTreeViewItem> treeViewFolders = new Dictionary <string, PackageImportTreeView.PackageImportTreeViewItem>();

                AssetsItem[] assetItems2 = this.m_AssetItems;
                for (int j = 0; j < assetItems2.Length; j++)
                {
                    AssetsItem assetsItem2 = assetItems2[j];
                    if (assetsItem2.assetIsDir != 1)
                    {
                        if (!PackageImport.HasInvalidCharInFilePath(assetsItem2.pathName))
                        {
                            string       fileName      = Path.GetFileName(assetsItem2.pathName);
                            string       directoryName = Path.GetDirectoryName(assetsItem2.pathName);
                            TreeViewItem treeViewItem  = this.EnsureFolderPath(directoryName, dictionary, treeViewFolders, flag);
                            if (treeViewItem != null)
                            {
                                int hashCode = assetsItem2.pathName.GetHashCode();
                                treeViewItem.AddChild(new PackageImportTreeView.PackageImportTreeViewItem(hashCode, treeViewItem.depth + 1, treeViewItem, fileName)
                                {
                                    item = assetsItem2
                                });
                            }
                        }
                    }
                }
                if (flag)
                {
                    this.m_TreeView.state.expandedIDs.Sort();
                }
            }
示例#3
0
        protected override TreeViewItem BuildRoot()
        {
            TreeViewItem treeViewItem = new TreeViewItem(-1, -1);

            treeViewItem.children = new List <TreeViewItem>();
            List <EditorBuildSettingsScene> list = new List <EditorBuildSettingsScene>(EditorBuildSettings.scenes);

            foreach (EditorBuildSettingsScene current in list)
            {
                BuildPlayerSceneTreeViewItem child = new BuildPlayerSceneTreeViewItem(current.guid.GetHashCode(), 0, current.path, current.enabled);
                treeViewItem.AddChild(child);
            }
            return(treeViewItem);
        }
            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);
            }
示例#5
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);
            }
        void AddDebugItems(TreeViewItem hiddenRoot, IdSequence idSequence)
        {
            var debugItem = new TreeViewItem(idSequence.get(), 0, "<Debug raw list of modifications>");

            foreach (var mod in m_AllModifications.addedGameObjects)
            {
                debugItem.AddChild(new TreeViewItem(idSequence.get(), debugItem.depth + 1, mod.instanceGameObject.name + " (Added GameObject)"));
            }
            foreach (var mod in m_AllModifications.removedGameObjects)
            {
                debugItem.AddChild(new TreeViewItem(idSequence.get(), debugItem.depth + 1, mod.assetGameObject.name + " (Removed GameObject)"));
            }
            foreach (var mod in m_AllModifications.addedComponents)
            {
                debugItem.AddChild(new TreeViewItem(idSequence.get(), debugItem.depth + 1, mod.instanceComponent.GetType() + " (Added Component)"));
            }
            foreach (var mod in m_AllModifications.removedComponents)
            {
                debugItem.AddChild(new TreeViewItem(idSequence.get(), debugItem.depth + 1, mod.assetComponent.GetType() + " (Removed Component)"));
            }

            hiddenRoot.AddChild(new TreeViewItem()); // spacer
            hiddenRoot.AddChild(debugItem);
        }
        protected override TreeViewItem BuildRoot()
        {
            var root = new TreeViewItem(-1, -1);

            root.children = new List <TreeViewItem>();

            List <EditorBuildSettingsScene> scenes = new List <EditorBuildSettingsScene>(EditorBuildSettings.scenes);

            foreach (var sc in scenes)
            {
                var item = new BuildPlayerSceneTreeViewItem(sc.guid.GetHashCode(), 0, sc.guid, sc.enabled);
                root.AddChild(item);
            }
            return(root);
        }
            public override void FetchData()
            {
                int depth = -1;

                base.m_RootItem = new PackageImportTreeView.PackageImportTreeViewItem("Assets".GetHashCode(), depth, null, "InvisibleAssetsFolder");
                ((PackageImportTreeView.PackageImportTreeViewItem)base.m_RootItem).isFolder = true;
                bool initExpandedState = base.m_TreeView.state.expandedIDs.Count == 0;

                if (initExpandedState)
                {
                    base.m_TreeView.state.expandedIDs.Add(base.m_RootItem.id);
                }
                Dictionary <string, AssetsItem> packageFolders = new Dictionary <string, AssetsItem>();

                foreach (AssetsItem item in this.m_AssetItems)
                {
                    if (item.assetIsDir == 1)
                    {
                        packageFolders[item.pathName] = item;
                    }
                }
                Dictionary <string, PackageImportTreeView.PackageImportTreeViewItem> treeViewFolders = new Dictionary <string, PackageImportTreeView.PackageImportTreeViewItem>();

                foreach (AssetsItem item2 in this.m_AssetItems)
                {
                    if ((item2.assetIsDir != 1) && !PackageImport.HasInvalidCharInFilePath(item2.pathName))
                    {
                        string       fileName      = Path.GetFileName(item2.pathName);
                        string       directoryName = Path.GetDirectoryName(item2.pathName);
                        TreeViewItem parent        = this.EnsureFolderPath(directoryName, packageFolders, treeViewFolders, initExpandedState);
                        if (parent != null)
                        {
                            PackageImportTreeView.PackageImportTreeViewItem child = new PackageImportTreeView.PackageImportTreeViewItem(item2.pathName.GetHashCode(), parent.depth + 1, parent, fileName)
                            {
                                item = item2
                            };
                            parent.AddChild(child);
                        }
                    }
                }
                if (initExpandedState)
                {
                    base.m_TreeView.state.expandedIDs.Sort();
                }
            }
            public override void FetchData()
            {
                int depth = -1;

                this.m_RootItem = new PackageImportTreeView.PackageImportTreeViewItem(null, "Assets".GetHashCode(), depth, null, "InvisibleAssetsFolder");
                bool flag = true;

                if (flag)
                {
                    this.m_TreeView.state.expandedIDs.Add(this.m_RootItem.id);
                }
                ImportPackageItem[] packageItems = this.m_PackageImportView.packageItems;
                Dictionary <string, PackageImportTreeView.PackageImportTreeViewItem> dictionary = new Dictionary <string, PackageImportTreeView.PackageImportTreeViewItem>();

                for (int i = 0; i < packageItems.Length; i++)
                {
                    ImportPackageItem importPackageItem = packageItems[i];
                    if (!PackageImport.HasInvalidCharInFilePath(importPackageItem.destinationAssetPath))
                    {
                        string       fileName      = Path.GetFileName(importPackageItem.destinationAssetPath);
                        string       directoryName = Path.GetDirectoryName(importPackageItem.destinationAssetPath);
                        TreeViewItem treeViewItem  = this.EnsureFolderPath(directoryName, dictionary, flag);
                        if (treeViewItem != null)
                        {
                            int hashCode = importPackageItem.destinationAssetPath.GetHashCode();
                            PackageImportTreeView.PackageImportTreeViewItem packageImportTreeViewItem = new PackageImportTreeView.PackageImportTreeViewItem(importPackageItem, hashCode, treeViewItem.depth + 1, treeViewItem, fileName);
                            treeViewItem.AddChild(packageImportTreeViewItem);
                            if (flag)
                            {
                                this.m_TreeView.state.expandedIDs.Add(hashCode);
                            }
                            if (importPackageItem.isFolder)
                            {
                                dictionary[importPackageItem.destinationAssetPath] = packageImportTreeViewItem;
                            }
                        }
                    }
                }
                if (flag)
                {
                    this.m_TreeView.state.expandedIDs.Sort();
                }
            }
            public override void FetchData()
            {
                int depth = -1;

                this.m_RootItem = new PackageExportTreeView.PackageExportTreeViewItem(null, "Assets".GetHashCode(), depth, null, "InvisibleAssetsFolder");
                bool flag = true;

                if (flag)
                {
                    this.m_TreeView.state.expandedIDs.Add(this.m_RootItem.id);
                }
                ExportPackageItem[] items = this.m_PackageExportView.items;
                Dictionary <string, PackageExportTreeView.PackageExportTreeViewItem> dictionary = new Dictionary <string, PackageExportTreeView.PackageExportTreeViewItem>();

                for (int i = 0; i < items.Length; i++)
                {
                    ExportPackageItem exportPackageItem = items[i];
                    if (!PackageImport.HasInvalidCharInFilePath(exportPackageItem.assetPath))
                    {
                        string       displayName  = Path.GetFileName(exportPackageItem.assetPath).ConvertSeparatorsToUnity();
                        string       folderPath   = Path.GetDirectoryName(exportPackageItem.assetPath).ConvertSeparatorsToUnity();
                        TreeViewItem treeViewItem = this.EnsureFolderPath(folderPath, dictionary, flag);
                        if (treeViewItem != null)
                        {
                            int hashCode = exportPackageItem.assetPath.GetHashCode();
                            PackageExportTreeView.PackageExportTreeViewItem packageExportTreeViewItem = new PackageExportTreeView.PackageExportTreeViewItem(exportPackageItem, hashCode, treeViewItem.depth + 1, treeViewItem, displayName);
                            treeViewItem.AddChild(packageExportTreeViewItem);
                            if (flag)
                            {
                                this.m_TreeView.state.expandedIDs.Add(hashCode);
                            }
                            if (exportPackageItem.isFolder)
                            {
                                dictionary[exportPackageItem.assetPath] = packageExportTreeViewItem;
                            }
                        }
                    }
                }
                if (flag)
                {
                    this.m_TreeView.state.expandedIDs.Sort();
                }
            }
            public override void FetchData()
            {
                int depth = -1;

                base.m_RootItem = new PackageExportTreeView.PackageExportTreeViewItem(null, "Assets".GetHashCode(), depth, null, "InvisibleAssetsFolder");
                bool initExpandedState = true;

                if (initExpandedState)
                {
                    base.m_TreeView.state.expandedIDs.Add(base.m_RootItem.id);
                }
                ExportPackageItem[] items = this.m_PackageExportView.items;
                Dictionary <string, PackageExportTreeView.PackageExportTreeViewItem> treeViewFolders = new Dictionary <string, PackageExportTreeView.PackageExportTreeViewItem>();

                for (int i = 0; i < items.Length; i++)
                {
                    ExportPackageItem itemIn = items[i];
                    if (!PackageImport.HasInvalidCharInFilePath(itemIn.assetPath))
                    {
                        string       fileName      = Path.GetFileName(itemIn.assetPath);
                        string       directoryName = Path.GetDirectoryName(itemIn.assetPath);
                        TreeViewItem parent        = this.EnsureFolderPath(directoryName, treeViewFolders, initExpandedState);
                        if (parent != null)
                        {
                            int hashCode = itemIn.assetPath.GetHashCode();
                            PackageExportTreeView.PackageExportTreeViewItem child = new PackageExportTreeView.PackageExportTreeViewItem(itemIn, hashCode, parent.depth + 1, parent, fileName);
                            parent.AddChild(child);
                            if (initExpandedState)
                            {
                                base.m_TreeView.state.expandedIDs.Add(hashCode);
                            }
                            if (itemIn.isFolder)
                            {
                                treeViewFolders[itemIn.assetPath] = child;
                            }
                        }
                    }
                }
                if (initExpandedState)
                {
                    base.m_TreeView.state.expandedIDs.Sort();
                }
            }
示例#12
0
            public override void FetchData()
            {
                this.m_RootItem = (TreeViewItem) new PackageExportTreeView.PackageExportTreeViewItem((ExportPackageItem)null, "Assets".GetHashCode(), -1, (TreeViewItem)null, "InvisibleAssetsFolder");
                bool initExpandedState = true;

                if (initExpandedState)
                {
                    this.m_TreeView.state.expandedIDs.Add(this.m_RootItem.id);
                }
                ExportPackageItem[] items = this.m_PackageExportView.items;
                Dictionary <string, PackageExportTreeView.PackageExportTreeViewItem> treeViewFolders = new Dictionary <string, PackageExportTreeView.PackageExportTreeViewItem>();

                for (int index = 0; index < items.Length; ++index)
                {
                    ExportPackageItem itemIn = items[index];
                    if (!PackageImport.HasInvalidCharInFilePath(itemIn.assetPath))
                    {
                        string       fileName = Path.GetFileName(itemIn.assetPath);
                        TreeViewItem parent   = this.EnsureFolderPath(Path.GetDirectoryName(itemIn.assetPath), treeViewFolders, initExpandedState);
                        if (parent != null)
                        {
                            int hashCode = itemIn.assetPath.GetHashCode();
                            PackageExportTreeView.PackageExportTreeViewItem exportTreeViewItem = new PackageExportTreeView.PackageExportTreeViewItem(itemIn, hashCode, parent.depth + 1, parent, fileName);
                            parent.AddChild((TreeViewItem)exportTreeViewItem);
                            if (initExpandedState)
                            {
                                this.m_TreeView.state.expandedIDs.Add(hashCode);
                            }
                            if (itemIn.isFolder)
                            {
                                treeViewFolders[itemIn.assetPath] = exportTreeViewItem;
                            }
                        }
                    }
                }
                if (!initExpandedState)
                {
                    return;
                }
                this.m_TreeView.state.expandedIDs.Sort();
            }
示例#13
0
        protected override IList <TreeViewItem> BuildRows(TreeViewItem root)
        {
            if (menuTreeItems == null || menuTreeItems.Count == 0)
            {
                return(base.BuildRows(root));
            }
            root.children = new List <TreeViewItem>();
            int id = 0;

            foreach (var item in menuTreeItems)
            {
                item.Id = id++;
                var subTree = new TreeViewItem
                {
                    id          = item.Id,
                    displayName = item.Name,
                };
                root.AddChild(subTree);
            }
            SetupDepthsFromParentsAndChildren(root);
            return(base.BuildRows(root));
        }
            private TreeViewItem EnsureFolderPath(string folderPath, Dictionary <string, AssetsItem> packageFolders, Dictionary <string, PackageImportTreeView.PackageImportTreeViewItem> treeViewFolders, bool initExpandedState)
            {
                TreeViewItem item = TreeViewUtility.FindItem(folderPath.GetHashCode(), base.m_RootItem);

                if (item != null)
                {
                    return(item);
                }
                char[]       separator = new char[] { '/' };
                string[]     strArray  = folderPath.Split(separator);
                string       key       = string.Empty;
                TreeViewItem rootItem  = base.m_RootItem;

                for (int i = 0; i < strArray.Length; i++)
                {
                    string displayName = strArray[i];
                    if (key != string.Empty)
                    {
                        key = key + '/';
                    }
                    key = key + displayName;
                    if (key != "Assets")
                    {
                        PackageImportTreeView.PackageImportTreeViewItem item3;
                        int hashCode = key.GetHashCode();
                        if (treeViewFolders.TryGetValue(key, out item3))
                        {
                            rootItem = item3;
                        }
                        else
                        {
                            AssetsItem item5;
                            int        depth = i - 1;
                            PackageImportTreeView.PackageImportTreeViewItem child = new PackageImportTreeView.PackageImportTreeViewItem(hashCode, depth, rootItem, displayName)
                            {
                                isFolder = true
                            };
                            if (packageFolders.TryGetValue(key, out item5))
                            {
                                child.item = item5;
                            }
                            if (child.item == null)
                            {
                                AssetsItem item6 = new AssetsItem {
                                    assetIsDir        = 1,
                                    pathName          = key,
                                    exportedAssetPath = key,
                                    enabled           = (this.m_EnabledFolders != null) ? (!this.m_EnabledFolders.Contains(key) ? 0 : 1) : 1,
                                    guid        = AssetDatabase.AssetPathToGUID(key),
                                    previewPath = string.Empty
                                };
                                child.item        = item6;
                                child.item.exists = !string.IsNullOrEmpty(child.item.guid) ? 1 : 0;
                            }
                            rootItem.AddChild(child);
                            rootItem = child;
                            if (initExpandedState)
                            {
                                base.m_TreeView.state.expandedIDs.Add(hashCode);
                            }
                            treeViewFolders[key] = child;
                        }
                    }
                }
                return(rootItem);
            }
        protected override IList <TreeViewItem> BuildRows(TreeViewItem root)
        {
            //Debug.Log(sortCol + " " + sortColumn.sortedAscending);
            profilerState.lastFrame = profilerState.profilerWindow.GetActiveVisibleFrameIndex();

            var rows = new List <TreeViewItem>();

            if (property == null || !property.frameDataReady)
            {
                return(rows);
            }
            m_AllCanvasesItem = new RootTreeViewItem();
            SetExpanded(m_AllCanvasesItem.id, true);
            root.AddChild(m_AllCanvasesItem);
            UISystemProfilerInfo[] UISystemData = property.GetUISystemProfilerInfo();
            int[] allBatchesInstanceIDs         = property.GetUISystemBatchInstanceIDs();

            if (UISystemData != null)
            {
                Dictionary <int, TreeViewItem> map = new Dictionary <int, TreeViewItem>();
                int batchIndex = 0;
                foreach (var data in UISystemData)
                {
                    TreeViewItem parent;
                    if (!map.TryGetValue(data.parentId, out parent))
                    {
                        parent = m_AllCanvasesItem;
                        m_AllCanvasesItem.totalBatchCount  += data.totalBatchCount;
                        m_AllCanvasesItem.totalVertexCount += data.totalVertexCount;
                        m_AllCanvasesItem.gameObjectCount  += data.instanceIDsCount;
                    }
                    string           name;
                    BaseTreeViewItem canvasTreeViewItem;
                    if (data.isBatch)
                    {
                        name = "Batch " + batchIndex++;
                        canvasTreeViewItem = new BatchTreeViewItem(data, parent.depth + 1, name, allBatchesInstanceIDs);
                    }
                    else
                    {
                        name = property.GetUISystemProfilerNameByOffset(data.objectNameOffset);
                        canvasTreeViewItem         = new CanvasTreeViewItem(data, parent.depth + 1, name);
                        batchIndex                 = 0;
                        map[data.objectInstanceId] = canvasTreeViewItem;
                    }
                    if (!IsExpanded(parent.id))
                    {
                        if (!parent.hasChildren)
                        {
                            parent.children = CreateChildListForCollapsedParent();
                        }
                        continue;
                    }
                    parent.AddChild(canvasTreeViewItem);
                }

                m_Comparer.Col = Column.Element;
                if (multiColumnHeader.sortedColumnIndex != -1)
                {
                    m_Comparer.Col = (Column)multiColumnHeader.sortedColumnIndex;
                }
                m_Comparer.isAscending = multiColumnHeader.GetColumn((int)m_Comparer.Col).sortedAscending;

                SetupRows(m_AllCanvasesItem, rows);
            }
            return(rows);
        }
            TreeViewItem EnsureFolderPath(string folderPath, Dictionary <string, PackageImportTreeViewItem> treeViewFolders, bool initExpandedState)
            {
                //We're in the root folder, so just return the root item as the parent.
                if (folderPath == "")
                {
                    return(m_RootItem);
                }

                // Does folder path exist?
                int          id   = folderPath.GetHashCode();
                TreeViewItem item = TreeViewUtility.FindItem(id, m_RootItem);

                if (item != null)
                {
                    return(item);
                }

                // Add folders as needed
                string[]     splitPath   = folderPath.Split('/');
                string       currentPath = "";
                TreeViewItem currentItem = m_RootItem;
                int          folderDepth = -1; // Will be incremented to the right depth in the loop.

                for (int depth = 0; depth < splitPath.Length; ++depth)
                {
                    string folder = splitPath[depth];
                    if (currentPath != "")
                    {
                        currentPath += '/';
                    }

                    currentPath += folder;

                    // Dont create a 'Assets' folder (we already have that as a hidden root)
                    if (depth == 0 && currentPath == "Assets")
                    {
                        continue;
                    }

                    // Only increment the folder depth if we are past the root "Assets" folder.
                    ++folderDepth;

                    id = currentPath.GetHashCode();

                    PackageImportTreeViewItem foundItem;
                    if (treeViewFolders.TryGetValue(currentPath, out foundItem))
                    {
                        currentItem = foundItem;
                    }
                    else
                    {
                        // If we do not have a tree view item for this folder we create one
                        var folderItem = new PackageImportTreeViewItem(null, id, folderDepth, currentItem, folder);

                        // Add to children array of the parent
                        currentItem.AddChild(folderItem);
                        currentItem = folderItem;

                        // Auto expand all folder items
                        if (initExpandedState)
                        {
                            m_TreeView.state.expandedIDs.Add(id);
                        }

                        // For faster finding of folders
                        treeViewFolders[currentPath] = folderItem;
                    }
                }

                return(currentItem);
            }
        // Returns true if input gameobject or any of its descendants have modifications, otherwise returns false.
        bool AddTreeViewItemRecursive(TreeViewItem parentItem, GameObject gameObject, Dictionary <int, PrefabOverrides> prefabOverrideMap, IdSequence idSequence)
        {
            var gameObjectItem = new PrefabOverridesTreeViewItem
                                 (
                idSequence.get(),
                parentItem.depth + 1,
                gameObject.name
                                 );

            gameObjectItem.obj = gameObject;
            // We don't know yet if this item should be added to the parent.
            bool shouldAddGameObjectItemToParent = false;

            PrefabOverrides objectModifications;

            prefabOverrideMap.TryGetValue(gameObject.GetInstanceID(), out objectModifications);
            if (objectModifications != null)
            {
                // Added GameObject - note that this earlies out!
                AddedGameObject addedGameObjectData = objectModifications.addedGameObjects.Find(x => x.instanceGameObject == gameObject);
                if (addedGameObjectData != null)
                {
                    gameObjectItem.singleModification = addedGameObjectData;
                    gameObjectItem.type = ItemType.ADDED_OBJECT;

                    parentItem.AddChild(gameObjectItem);
                    return(true);
                }
                else
                {
                    // Modified GameObject
                    ObjectOverride modifiedGameObjectData = objectModifications.objectOverrides.Find(x => x.instanceObject == gameObject);
                    if (modifiedGameObjectData != null)
                    {
                        gameObjectItem.singleModification = modifiedGameObjectData;
                        gameObjectItem.type             = ItemType.PREFAB_OBJECT;
                        shouldAddGameObjectItemToParent = true;
                    }
                }

                // Added components and component modifications
                foreach (var component in gameObject.GetComponents(typeof(Component)))
                {
                    var componentItem = new PrefabOverridesTreeViewItem
                                        (
                        idSequence.get(),
                        gameObjectItem.depth + 1,
                        ObjectNames.GetInspectorTitle(component)
                                        );
                    componentItem.obj = component;

                    AddedComponent addedComponentData = objectModifications.addedComponents.Find(x => x.instanceComponent == component);
                    if (addedComponentData != null)
                    {
                        componentItem.singleModification = addedComponentData;
                        componentItem.type = ItemType.ADDED_OBJECT;
                        gameObjectItem.AddChild(componentItem);
                        shouldAddGameObjectItemToParent = true;
                    }
                    else
                    {
                        ObjectOverride modifiedObjectData = objectModifications.objectOverrides.Find(x => x.instanceObject == component);
                        if (modifiedObjectData != null)
                        {
                            componentItem.singleModification = modifiedObjectData;
                            componentItem.type = ItemType.PREFAB_OBJECT;
                            gameObjectItem.AddChild(componentItem);
                            shouldAddGameObjectItemToParent = true;
                        }
                    }
                }

                // Removed components
                foreach (var removedComponent in objectModifications.removedComponents)
                {
                    var removedComponentItem = new PrefabOverridesTreeViewItem
                                               (
                        idSequence.get(),
                        gameObjectItem.depth + 1,
                        ObjectNames.GetInspectorTitle(removedComponent.assetComponent)
                                               );
                    removedComponentItem.obj = removedComponent.assetComponent;
                    removedComponentItem.singleModification = removedComponent;
                    removedComponentItem.type = ItemType.REMOVED_OBJECT;
                    gameObjectItem.AddChild(removedComponentItem);
                    shouldAddGameObjectItemToParent = true;
                }
            }

            // Recurse into children
            foreach (Transform childTransform in gameObject.transform)
            {
                var childGameObject = childTransform.gameObject;
                shouldAddGameObjectItemToParent |= AddTreeViewItemRecursive(gameObjectItem, childGameObject, prefabOverrideMap, idSequence);
            }

            if (shouldAddGameObjectItemToParent)
            {
                parentItem.AddChild(gameObjectItem);
                return(true);
            }

            return(false);
        }
示例#18
0
        public override void FetchData()
        {
            m_RootItem = new TreeViewItem(0, 0, null, "Invisible Root Item");
            SetExpanded(m_RootItem, true); // ensure always visible

            // We want three roots: Favorites, Assets, and Saved Filters
            List <TreeViewItem> visibleRoots = new List <TreeViewItem>();

            // Fetch asset folders
            int          assetsFolderInstanceID = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID("Assets");
            int          depth         = 0;
            string       displayName   = "Assets"; //CreateDisplayName (assetsFolderInstanceID);
            TreeViewItem assetRootItem = new TreeViewItem(assetsFolderInstanceID, depth, m_RootItem, displayName);

            ReadAssetDatabase("Assets", assetRootItem, depth + 1);

            var          packagesMountPoint = PackageManager.Folders.GetPackagesMountPoint();
            TreeViewItem packagesRootItem   = new TreeViewItem(ProjectBrowser.kPackagesFolderInstanceId, depth, m_RootItem, packagesMountPoint);

            depth++;

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

            packagesRootItem.icon = emptyFolderIcon;

            var packages = PackageManager.Packages.GetAll();

            foreach (var package in packages)
            {
                if (package.source == PackageManager.PackageSource.BuiltIn)
                {
                    continue;
                }

                var packageFolderInstanceId = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID(package.assetPath);

                displayName = !string.IsNullOrEmpty(package.displayName) ? package.displayName : package.name;
                TreeViewItem packageItem = new TreeViewItem(packageFolderInstanceId, depth, packagesRootItem, displayName);
                packagesRootItem.AddChild(packageItem);
                ReadAssetDatabase(package.assetPath, packageItem, depth + 1);
                packagesRootItem.icon = folderIcon;
            }

            // Fetch saved filters
            TreeViewItem savedFiltersRootItem = SavedSearchFilters.ConvertToTreeView();

            savedFiltersRootItem.parent = m_RootItem;

            // Order
            visibleRoots.Add(savedFiltersRootItem);
            visibleRoots.Add(assetRootItem);

            if (packagesRootItem != null)
            {
                visibleRoots.Add(packagesRootItem);
            }

            m_RootItem.children = visibleRoots;

            // Get global expanded state of roots
            foreach (TreeViewItem item in m_RootItem.children)
            {
                // Do not expand Packages root item
                if (item.id == ProjectBrowser.kPackagesFolderInstanceId)
                {
                    continue;
                }
                bool expanded = EditorPrefs.GetBool(kProjectBrowserString + item.displayName, true);
                SetExpanded(item, expanded);
            }

            m_NeedRefreshRows = true;
        }
            private TreeViewItem EnsureFolderPath(string folderPath, Dictionary <string, AssetsItem> packageFolders, Dictionary <string, PackageImportTreeView.PackageImportTreeViewItem> treeViewFolders, bool initExpandedState)
            {
                int          hashCode     = folderPath.GetHashCode();
                TreeViewItem treeViewItem = TreeViewUtility.FindItem(hashCode, this.m_RootItem);

                if (treeViewItem != null)
                {
                    return(treeViewItem);
                }
                string[] array = folderPath.Split(new char[]
                {
                    '/'
                });
                string       text          = string.Empty;
                TreeViewItem treeViewItem2 = this.m_RootItem;

                for (int i = 0; i < array.Length; i++)
                {
                    string text2 = array[i];
                    if (text != string.Empty)
                    {
                        text += '/';
                    }
                    text += text2;
                    if (!(text == "Assets"))
                    {
                        hashCode = text.GetHashCode();
                        PackageImportTreeView.PackageImportTreeViewItem packageImportTreeViewItem;
                        if (treeViewFolders.TryGetValue(text, out packageImportTreeViewItem))
                        {
                            treeViewItem2 = packageImportTreeViewItem;
                        }
                        else
                        {
                            PackageImportTreeView.PackageImportTreeViewItem packageImportTreeViewItem2 = new PackageImportTreeView.PackageImportTreeViewItem(hashCode, i, treeViewItem2, text2);
                            packageImportTreeViewItem2.isFolder = true;
                            AssetsItem item;
                            if (packageFolders.TryGetValue(text, out item))
                            {
                                packageImportTreeViewItem2.item = item;
                            }
                            if (packageImportTreeViewItem2.item == null)
                            {
                                packageImportTreeViewItem2.item = new AssetsItem
                                {
                                    assetIsDir        = 1,
                                    pathName          = text,
                                    exportedAssetPath = text,
                                    enabled           = (this.m_EnabledFolders != null) ? ((!this.m_EnabledFolders.Contains(text)) ? 0 : 1) : 1,
                                    guid        = AssetDatabase.AssetPathToGUID(text),
                                    previewPath = string.Empty
                                };
                                packageImportTreeViewItem2.item.exists = ((!string.IsNullOrEmpty(packageImportTreeViewItem2.item.guid)) ? 1 : 0);
                            }
                            treeViewItem2.AddChild(packageImportTreeViewItem2);
                            treeViewItem2 = packageImportTreeViewItem2;
                            if (initExpandedState)
                            {
                                this.m_TreeView.state.expandedIDs.Add(hashCode);
                            }
                            treeViewFolders[text] = packageImportTreeViewItem2;
                        }
                    }
                }
                return(treeViewItem2);
            }
        // Returns true if input gameobject or any of its descendants have modifications, otherwise returns false.
        bool AddTreeViewItemRecursive(TreeViewItem parentItem, GameObject gameObject, Dictionary <int, PrefabOverrides> prefabOverrideMap, IdSequence idSequence)
        {
            var gameObjectItem = new PrefabOverridesTreeViewItem
                                 (
                gameObject.GetInstanceID(),
                parentItem.depth + 1,
                gameObject.name
                                 );

            gameObjectItem.obj = gameObject;

            // We don't know yet if this item should be added to the parent.
            bool shouldAddGameObjectItemToParent = false;

            PrefabOverrides objectModifications;

            prefabOverrideMap.TryGetValue(gameObject.GetInstanceID(), out objectModifications);
            if (objectModifications != null)
            {
                // Added GameObject - note that this earlies out!
                AddedGameObject addedGameObjectData = objectModifications.addedGameObjects.Find(x => x.instanceGameObject == gameObject);
                if (addedGameObjectData != null)
                {
                    gameObjectItem.singleModification = addedGameObjectData;
                    gameObjectItem.type = ItemType.ADDED_OBJECT;

                    parentItem.AddChild(gameObjectItem);
                    return(true);
                }
                else
                {
                    // Modified GameObject
                    ObjectOverride modifiedGameObjectData = objectModifications.objectOverrides.Find(x => x.instanceObject == gameObject);
                    if (modifiedGameObjectData != null)
                    {
                        gameObjectItem.singleModification = modifiedGameObjectData;
                        gameObjectItem.type             = ItemType.PREFAB_OBJECT;
                        shouldAddGameObjectItemToParent = true;
                    }
                }

                // Added components and component modifications
                foreach (var component in gameObject.GetComponents(typeof(Component)))
                {
                    // GetComponents will return Missing Script components as null, we will skip them here to prevent NullReferenceExceptions. (case 1197599)
                    if (component == null)
                    {
                        continue;
                    }

                    // Skip coupled components (they are merged into the display of their owning component)
                    if (component.IsCoupledComponent())
                    {
                        continue;
                    }

                    var componentItem = new PrefabOverridesTreeViewItem
                                        (
                        component.GetInstanceID(),
                        gameObjectItem.depth + 1,
                        ObjectNames.GetInspectorTitle(component)
                                        );
                    componentItem.obj = component;

                    AddedComponent addedComponentData = objectModifications.addedComponents.Find(x => x.instanceComponent == component);
                    if (addedComponentData != null)
                    {
                        // Skip coupled components (they are merged into the display of their owning component)
                        if (addedComponentData.instanceComponent.IsCoupledComponent())
                        {
                            continue;
                        }

                        componentItem.singleModification = addedComponentData;
                        componentItem.type = ItemType.ADDED_OBJECT;
                        gameObjectItem.AddChild(componentItem);
                        shouldAddGameObjectItemToParent = true;
                    }
                    else
                    {
                        var            coupledComponent          = component.GetCoupledComponent();
                        ObjectOverride modifiedObjectData        = objectModifications.objectOverrides.Find(x => x.instanceObject == component);
                        ObjectOverride modifiedCoupledObjectData = (coupledComponent != null) ? objectModifications.objectOverrides.Find(x => x.instanceObject == coupledComponent) : null;

                        if (modifiedObjectData != null || modifiedCoupledObjectData != null)
                        {
                            // If only the coupled component has modifications, create an
                            // ObjectOverride object for the main component since it doesn't exist yet.
                            if (modifiedObjectData == null)
                            {
                                modifiedObjectData = new ObjectOverride()
                                {
                                    instanceObject = component
                                }
                            }
                            ;

                            modifiedObjectData.coupledOverride = modifiedCoupledObjectData;

                            componentItem.singleModification = modifiedObjectData;
                            componentItem.type = ItemType.PREFAB_OBJECT;
                            gameObjectItem.AddChild(componentItem);
                            shouldAddGameObjectItemToParent = true;
                        }
                    }
                }

                // Removed components
                foreach (var removedComponent in objectModifications.removedComponents)
                {
                    // Skip coupled components (they are merged into the display of their owning component)
                    if (removedComponent.assetComponent.IsCoupledComponent())
                    {
                        continue;
                    }

                    var removedComponentItem = new PrefabOverridesTreeViewItem
                                               (
                        idSequence.get(),
                        gameObjectItem.depth + 1,
                        ObjectNames.GetInspectorTitle(removedComponent.assetComponent)
                                               );
                    removedComponentItem.obj = removedComponent.assetComponent;
                    removedComponentItem.singleModification = removedComponent;
                    removedComponentItem.type = ItemType.REMOVED_OBJECT;
                    gameObjectItem.AddChild(removedComponentItem);
                    shouldAddGameObjectItemToParent = true;
                }
            }

            // Recurse into children
            foreach (Transform childTransform in gameObject.transform)
            {
                var childGameObject = childTransform.gameObject;
                shouldAddGameObjectItemToParent |= AddTreeViewItemRecursive(gameObjectItem, childGameObject, prefabOverrideMap, idSequence);
            }

            if (shouldAddGameObjectItemToParent)
            {
                parentItem.AddChild(gameObjectItem);
                if (maxDepthItem == null || gameObjectItem.depth > maxDepthItem.depth)
                {
                    maxDepthItem = gameObjectItem;
                }

                return(true);
            }

            return(false);
        }
示例#21
0
        protected override IList <TreeViewItem> BuildRows(TreeViewItem root)
        {
            this.profilerState.lastFrame = this.profilerState.profilerWindow.GetActiveVisibleFrameIndex();
            List <TreeViewItem>  list = new List <TreeViewItem>();
            IList <TreeViewItem> result;

            if (this.property == null || !this.property.frameDataReady)
            {
                result = list;
            }
            else
            {
                this.m_AllCanvasesItem = new UISystemProfilerTreeView.RootTreeViewItem();
                base.SetExpanded(this.m_AllCanvasesItem.id, true);
                root.AddChild(this.m_AllCanvasesItem);
                UISystemProfilerInfo[] uISystemProfilerInfo = this.property.GetUISystemProfilerInfo();
                int[] uISystemBatchInstanceIDs = this.property.GetUISystemBatchInstanceIDs();
                if (uISystemProfilerInfo != null)
                {
                    Dictionary <int, TreeViewItem> dictionary = new Dictionary <int, TreeViewItem>();
                    int num = 0;
                    UISystemProfilerInfo[] array = uISystemProfilerInfo;
                    for (int i = 0; i < array.Length; i++)
                    {
                        UISystemProfilerInfo info = array[i];
                        TreeViewItem         allCanvasesItem;
                        if (!dictionary.TryGetValue(info.parentId, out allCanvasesItem))
                        {
                            allCanvasesItem = this.m_AllCanvasesItem;
                            this.m_AllCanvasesItem.totalBatchCount  += info.totalBatchCount;
                            this.m_AllCanvasesItem.totalVertexCount += info.totalVertexCount;
                            this.m_AllCanvasesItem.gameObjectCount  += info.instanceIDsCount;
                        }
                        UISystemProfilerTreeView.BaseTreeViewItem baseTreeViewItem;
                        if (info.isBatch)
                        {
                            string displayName = "Batch " + num++;
                            baseTreeViewItem = new UISystemProfilerTreeView.BatchTreeViewItem(info, allCanvasesItem.depth + 1, displayName, uISystemBatchInstanceIDs);
                        }
                        else
                        {
                            string displayName = this.property.GetUISystemProfilerNameByOffset(info.objectNameOffset);
                            baseTreeViewItem = new UISystemProfilerTreeView.CanvasTreeViewItem(info, allCanvasesItem.depth + 1, displayName);
                            num = 0;
                            dictionary[info.objectInstanceId] = baseTreeViewItem;
                        }
                        if (!base.IsExpanded(allCanvasesItem.id))
                        {
                            if (!allCanvasesItem.hasChildren)
                            {
                                allCanvasesItem.children = TreeView.CreateChildListForCollapsedParent();
                            }
                        }
                        else
                        {
                            allCanvasesItem.AddChild(baseTreeViewItem);
                        }
                    }
                    this.m_Comparer.Col = UISystemProfilerTreeView.Column.Element;
                    if (base.multiColumnHeader.sortedColumnIndex != -1)
                    {
                        this.m_Comparer.Col = (UISystemProfilerTreeView.Column)base.multiColumnHeader.sortedColumnIndex;
                    }
                    this.m_Comparer.isAscending = base.multiColumnHeader.GetColumn((int)this.m_Comparer.Col).sortedAscending;
                    this.SetupRows(this.m_AllCanvasesItem, list);
                }
                result = list;
            }
            return(result);
        }