public override void FetchData()
        {
            this.m_RootItem = new TreeViewItem(int.MaxValue, 0, (TreeViewItem)null, "Invisible Root Item");
            this.SetExpanded(this.m_RootItem, true);
            List <TreeViewItem> treeViewItemList = new List <TreeViewItem>();
            int          folderInstanceId        = ProjectBrowserColumnOneTreeViewDataSource.GetAssetsFolderInstanceID();
            int          depth       = 0;
            string       displayName = "Assets";
            TreeViewItem parent      = new TreeViewItem(folderInstanceId, depth, this.m_RootItem, displayName);

            this.ReadAssetDatabase(parent, depth + 1);
            TreeViewItem treeView = SavedSearchFilters.ConvertToTreeView();

            treeView.parent = this.m_RootItem;
            treeViewItemList.Add(treeView);
            treeViewItemList.Add(parent);
            this.m_RootItem.children = treeViewItemList;
            using (List <TreeViewItem> .Enumerator enumerator = this.m_RootItem.children.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    TreeViewItem current = enumerator.Current;
                    bool         expand  = EditorPrefs.GetBool(ProjectBrowserColumnOneTreeViewDataSource.kProjectBrowserString + current.displayName, true);
                    this.SetExpanded(current, expand);
                }
            }
            this.m_NeedRefreshVisibleFolders = true;
        }
        public override void FetchData()
        {
            m_RootItem = new TreeViewItem(System.Int32.MaxValue, 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 = GetAssetsFolderInstanceID();
            int          depth         = 0;
            string       displayName   = "Assets"; //CreateDisplayName (assetsFolderInstanceID);
            TreeViewItem assetRootItem = new TreeViewItem(assetsFolderInstanceID, depth, m_RootItem, displayName);

            ReadAssetDatabase(HierarchyType.Assets, assetRootItem, depth + 1);

            // Fetch packages
            TreeViewItem packagesRootItem = null;

            if (Unsupported.IsDeveloperMode() && EditorPrefs.GetBool("ShowPackagesFolder"))
            {
                var    packagesFolderInstanceID = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID(AssetDatabase.GetPackagesMountPoint());
                string packagesDisplayName      = AssetDatabase.GetPackagesMountPoint();
                packagesRootItem = new TreeViewItem(packagesFolderInstanceID, depth, m_RootItem, packagesDisplayName);
                ReadAssetDatabase(HierarchyType.Packages, packagesRootItem, depth + 1);
            }

            // 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)
            {
                bool expanded = EditorPrefs.GetBool(kProjectBrowserString + item.displayName, true);
                SetExpanded(item, expanded);
            }

            m_NeedRefreshRows = true;
        }
 public override void FetchData()
 {
     base.m_RootItem = new TreeViewItem(0x7fffffff, 0, null, "Invisible Root Item");
     this.SetExpanded(base.m_RootItem, true);
     List<TreeViewItem> list = new List<TreeViewItem>();
     int assetsFolderInstanceID = GetAssetsFolderInstanceID();
     int depth = 0;
     string displayName = "Assets";
     TreeViewItem parent = new TreeViewItem(assetsFolderInstanceID, depth, base.m_RootItem, displayName);
     this.ReadAssetDatabase(parent, depth + 1);
     TreeViewItem item = SavedSearchFilters.ConvertToTreeView();
     item.parent = base.m_RootItem;
     list.Add(item);
     list.Add(parent);
     base.m_RootItem.children = list;
     foreach (TreeViewItem item3 in base.m_RootItem.children)
     {
         bool @bool = EditorPrefs.GetBool(kProjectBrowserString + item3.displayName, true);
         this.SetExpanded(item3, @bool);
     }
     base.m_NeedRefreshVisibleFolders = true;
 }
        public override void FetchData()
        {
            this.m_RootItem = new TreeViewItem(2147483647, 0, null, "Invisible Root Item");
            this.SetExpanded(this.m_RootItem, true);
            List <TreeViewItem> list            = new List <TreeViewItem>();
            int          assetsFolderInstanceID = ProjectBrowserColumnOneTreeViewDataSource.GetAssetsFolderInstanceID();
            int          num          = 0;
            string       displayName  = "Assets";
            TreeViewItem treeViewItem = new TreeViewItem(assetsFolderInstanceID, num, this.m_RootItem, displayName);

            this.ReadAssetDatabase(HierarchyType.Assets, treeViewItem, num + 1);
            TreeViewItem treeViewItem2 = null;

            if (Unsupported.IsDeveloperMode() && EditorPrefs.GetBool("ShowPackagesFolder"))
            {
                int    mainAssetOrInProgressProxyInstanceID = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID(AssetDatabase.GetPackagesMountPoint());
                string packagesMountPoint = AssetDatabase.GetPackagesMountPoint();
                treeViewItem2 = new TreeViewItem(mainAssetOrInProgressProxyInstanceID, num, this.m_RootItem, packagesMountPoint);
                this.ReadAssetDatabase(HierarchyType.Packages, treeViewItem2, num + 1);
            }
            TreeViewItem treeViewItem3 = SavedSearchFilters.ConvertToTreeView();

            treeViewItem3.parent = this.m_RootItem;
            list.Add(treeViewItem3);
            list.Add(treeViewItem);
            if (treeViewItem2 != null)
            {
                list.Add(treeViewItem2);
            }
            this.m_RootItem.children = list;
            foreach (TreeViewItem current in this.m_RootItem.children)
            {
                bool @bool = EditorPrefs.GetBool(ProjectBrowserColumnOneTreeViewDataSource.kProjectBrowserString + current.displayName, true);
                this.SetExpanded(current, @bool);
            }
            this.m_NeedRefreshRows = true;
        }
        public override void FetchData()
        {
            this.m_RootItem = new TreeViewItem(2147483647, 0, null, "Invisible Root Item");
            this.SetExpanded(this.m_RootItem, true);
            List <TreeViewItem> list            = new List <TreeViewItem>();
            int          assetsFolderInstanceID = ProjectBrowserColumnOneTreeViewDataSource.GetAssetsFolderInstanceID();
            int          num          = 0;
            string       displayName  = "Assets";
            TreeViewItem treeViewItem = new TreeViewItem(assetsFolderInstanceID, num, this.m_RootItem, displayName);

            this.ReadAssetDatabase(treeViewItem, num + 1);
            TreeViewItem treeViewItem2 = SavedSearchFilters.ConvertToTreeView();

            treeViewItem2.parent = this.m_RootItem;
            list.Add(treeViewItem2);
            list.Add(treeViewItem);
            this.m_RootItem.children = list;
            foreach (TreeViewItem current in this.m_RootItem.children)
            {
                bool @bool = EditorPrefs.GetBool(ProjectBrowserColumnOneTreeViewDataSource.kProjectBrowserString + current.displayName, true);
                this.SetExpanded(current, @bool);
            }
            this.m_NeedRefreshVisibleFolders = true;
        }
        public override void FetchData()
        {
            m_RootItem = new TreeViewItem(0, 0, null, "Invisible Root Item");
            SetExpanded(m_RootItem, true); // ensure always visible

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

            // 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);

            AssetsTreeViewDataSource.RootTreeItem assetRootItem = new AssetsTreeViewDataSource.RootTreeItem(assetsFolderInstanceID, depth, m_RootItem, displayName);
            assetRootItem.icon = folderIcon;
            ReadAssetDatabase("Assets", assetRootItem, depth + 1);

            // Fetch packages folder
            displayName = PackageManager.Folders.GetPackagesPath();
            AssetsTreeViewDataSource.RootTreeItem packagesRootItem = new AssetsTreeViewDataSource.RootTreeItem(ProjectBrowser.kPackagesFolderInstanceId, depth, m_RootItem, displayName);
            depth++;

            packagesRootItem.icon = folderIcon;

            var packages = PackageManagerUtilityInternal.GetAllVisiblePackages(skipHiddenPackages);

            foreach (var package in packages)
            {
                var packageFolderInstanceId = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID(package.assetPath);

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

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

            savedFiltersRootItem.parent = m_RootItem;

            // Order
            visibleRoots.Add(savedFiltersRootItem);
            visibleRoots.Add(assetRootItem);
            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;
        }
        public override void FetchData()
        {
            bool firstInitialize = !isInitialized;

            m_RootItem = new TreeViewItem(0, 0, null, "Invisible Root Item");
            SetExpanded(m_RootItem, true); // ensure always visible

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

            // Favorites root
            TreeViewItem savedFiltersRootItem = SavedSearchFilters.ConvertToTreeView();

            visibleRoots.Add(savedFiltersRootItem);

            // Assets root
            int    assetsFolderInstanceID = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID("Assets");
            int    depth       = 0;
            string displayName = "Assets";

            AssetsTreeViewDataSource.RootTreeItem assetRootItem = new AssetsTreeViewDataSource.RootTreeItem(assetsFolderInstanceID, depth, m_RootItem, displayName);
            assetRootItem.icon = s_FolderIcon;
            visibleRoots.Add(assetRootItem);

            // Packages root
            displayName = PackageManager.Folders.GetPackagesPath();
            AssetsTreeViewDataSource.RootTreeItem packagesRootItem = new AssetsTreeViewDataSource.RootTreeItem(ProjectBrowser.kPackagesFolderInstanceId, depth, m_RootItem, displayName);
            packagesRootItem.icon = s_FolderIcon;
            visibleRoots.Add(packagesRootItem);

            m_RootItem.children = visibleRoots;

            // Set global expanded state for roots from EditorPrefs (must be before building the rows)
            if (firstInitialize)
            {
                foreach (TreeViewItem item in m_RootItem.children)
                {
                    bool expanded = EditorPrefs.GetBool(kProjectBrowserString + item.displayName, true);
                    SetExpanded(item, expanded);
                }
            }

            // Build rows
            //-----------
            m_Rows = new List <TreeViewItem>(100);

            // Favorites
            savedFiltersRootItem.parent = m_RootItem;
            m_Rows.Add(savedFiltersRootItem);
            if (IsExpanded(savedFiltersRootItem))
            {
                foreach (var f in savedFiltersRootItem.children)
                {
                    m_Rows.Add(f);
                }
            }
            else
            {
                savedFiltersRootItem.children = CreateChildListForCollapsedParent();
            }

            // Asset folders
            m_Rows.Add(assetRootItem);
            ReadAssetDatabase("Assets", assetRootItem, depth + 1, m_Rows);

            // Individual Package folders (under the Packages root item)
            m_Rows.Add(packagesRootItem);
            var packages = PackageManagerUtilityInternal.GetAllVisiblePackages(skipHiddenPackages);

            if (IsExpanded(packagesRootItem))
            {
                depth++;
                foreach (var package in packages)
                {
                    var packageFolderInstanceId = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID(package.assetPath);

                    displayName = !string.IsNullOrEmpty(package.displayName) ? package.displayName : package.name;
                    AssetsTreeViewDataSource.PackageTreeItem packageItem = new AssetsTreeViewDataSource.PackageTreeItem(packageFolderInstanceId, depth, packagesRootItem, displayName);
                    packageItem.icon = s_FolderIcon;
                    packagesRootItem.AddChild(packageItem);
                    m_Rows.Add(packageItem);
                    ReadAssetDatabase(package.assetPath, packageItem, depth + 1, m_Rows);
                }
            }
            else
            {
                if (packages.Length > 0)
                {
                    packagesRootItem.children = CreateChildListForCollapsedParent();
                }
            }

            m_NeedRefreshRows = false;
        }
Example #8
0
        public override void FetchData()
        {
            m_RootItem = new TreeViewItem(System.Int32.MaxValue, 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 = GetAssetsFolderInstanceID();
            int          depth         = 0;
            string       displayName   = "Assets"; //CreateDisplayName (assetsFolderInstanceID);
            TreeViewItem assetRootItem = new TreeViewItem(assetsFolderInstanceID, depth, m_RootItem, displayName);

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

            TreeViewItem packagesRootItem = new TreeViewItem(0, depth, m_RootItem, "Packages");

            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 packagePath             = Path.Combine(PackageManager.Folders.GetPackagesMountPoint(), package.name);
                var packageFolderInstanceId = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID(packagePath);

                displayName = !string.IsNullOrEmpty(package.displayName) ? package.displayName : CultureInfo.InvariantCulture.TextInfo.ToTitleCase(package.name.Replace("com.unity.", ""));
                TreeViewItem packageItem = new TreeViewItem(packageFolderInstanceId, depth, null, displayName);
                packagesRootItem.AddChild(packageItem);
                ReadAssetDatabase(packagePath, 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)
            {
                bool expanded = EditorPrefs.GetBool(kProjectBrowserString + item.displayName, true);
                SetExpanded(item, expanded);
            }

            m_NeedRefreshRows = true;
        }