private void DoPreviewPopup(PackageImportTreeView.PackageImportTreeViewItem pitem, Rect rowRect)
            {
                ImportPackageItem item = pitem.item;

                if (item != null)
                {
                    if (((Event.current.type == EventType.MouseDown) && rowRect.Contains(Event.current.mousePosition)) && !PopupWindowWithoutFocus.IsVisible())
                    {
                        this.showPreviewForID = pitem.id;
                    }
                    if ((pitem.id == this.showPreviewForID) && (Event.current.type != EventType.Layout))
                    {
                        this.showPreviewForID = 0;
                        if (!string.IsNullOrEmpty(item.previewPath))
                        {
                            Texture2D preview       = PackageImport.GetPreview(item.previewPath);
                            Rect      activatorRect = rowRect;
                            activatorRect.width = EditorGUIUtility.currentViewWidth;
                            PopupLocationHelper.PopupLocation[] locationPriorityOrder = new PopupLocationHelper.PopupLocation[3];
                            locationPriorityOrder[0] = PopupLocationHelper.PopupLocation.Right;
                            locationPriorityOrder[1] = PopupLocationHelper.PopupLocation.Left;
                            PopupWindowWithoutFocus.Show(activatorRect, new PackageImportTreeView.PreviewPopup(preview), locationPriorityOrder);
                        }
                    }
                }
            }
        private void SelectionChanged(int[] selectedIDs)
        {
            this.m_Selection = new List <PackageImportTreeView.PackageImportTreeViewItem>();
            IList <TreeViewItem> rows = this.m_TreeView.data.GetRows();

            foreach (TreeViewItem current in rows)
            {
                if (selectedIDs.Contains(current.id))
                {
                    PackageImportTreeView.PackageImportTreeViewItem packageImportTreeViewItem = current as PackageImportTreeView.PackageImportTreeViewItem;
                    if (packageImportTreeViewItem != null)
                    {
                        this.m_Selection.Add(packageImportTreeViewItem);
                    }
                }
            }
            ImportPackageItem item = this.m_Selection[0].item;

            if (this.m_Selection.Count == 1 && item != null && !string.IsNullOrEmpty(item.previewPath))
            {
                PackageImportTreeView.PackageImportTreeViewGUI packageImportTreeViewGUI = this.m_TreeView.gui as PackageImportTreeView.PackageImportTreeViewGUI;
                packageImportTreeViewGUI.showPreviewForID = this.m_Selection[0].id;
            }
            else
            {
                PopupWindowWithoutFocus.Hide();
            }
        }
        private void SelectionChanged(int[] selectedIDs)
        {
            this.m_Selection = new List <PackageImportTreeViewItem>();
            foreach (TreeViewItem item in this.m_TreeView.data.GetRows())
            {
                if (selectedIDs.Contains <int>(item.id))
                {
                    PackageImportTreeViewItem item2 = item as PackageImportTreeViewItem;
                    if (item2 != null)
                    {
                        this.m_Selection.Add(item2);
                    }
                }
            }
            ImportPackageItem item3 = this.m_Selection[0].item;

            if (((this.m_Selection.Count == 1) && (item3 != null)) && !string.IsNullOrEmpty(item3.previewPath))
            {
                PackageImportTreeViewGUI gui = this.m_TreeView.gui as PackageImportTreeViewGUI;
                gui.showPreviewForID = this.m_Selection[0].id;
            }
            else
            {
                PopupWindowWithoutFocus.Hide();
            }
        }
        private EnabledState GetFolderChildrenEnabledState(PackageImportTreeViewItem folder)
        {
            ImportPackageItem item = folder.item;

            if ((item != null) && !item.isFolder)
            {
                Debug.LogError("Should be a folder item!");
            }
            if (!folder.hasChildren)
            {
                return(EnabledState.None);
            }
            EnabledState notSet             = EnabledState.NotSet;
            PackageImportTreeViewItem item2 = folder.children[0] as PackageImportTreeViewItem;
            ImportPackageItem         item3 = item2.item;
            int num = (item3 != null) ? item3.enabledStatus : 1;

            for (int i = 1; i < folder.children.Count; i++)
            {
                item3 = (folder.children[i] as PackageImportTreeViewItem).item;
                if (num != item3.enabledStatus)
                {
                    notSet = EnabledState.Mixed;
                    break;
                }
            }
            if (notSet == EnabledState.NotSet)
            {
                notSet = (num != 1) ? EnabledState.None : EnabledState.All;
            }
            return(notSet);
        }
        private void RecursiveComputeEnabledStateForFolders(PackageImportTreeViewItem pitem, HashSet <PackageImportTreeViewItem> done)
        {
            ImportPackageItem item = pitem.item;

            if ((item == null) || item.isFolder)
            {
                if (pitem.hasChildren)
                {
                    foreach (TreeViewItem item2 in pitem.children)
                    {
                        this.RecursiveComputeEnabledStateForFolders(item2 as PackageImportTreeViewItem, done);
                    }
                }
                if ((item != null) && !done.Contains(pitem))
                {
                    EnabledState folderChildrenEnabledState = this.GetFolderChildrenEnabledState(pitem);
                    item.enabledStatus = (int)folderChildrenEnabledState;
                    if (folderChildrenEnabledState == EnabledState.Mixed)
                    {
                        done.Add(pitem);
                        for (PackageImportTreeViewItem item3 = pitem.parent as PackageImportTreeViewItem; item3 != null; item3 = item3.parent as PackageImportTreeViewItem)
                        {
                            ImportPackageItem item4 = item3.item;
                            if ((item4 != null) && !done.Contains(item3))
                            {
                                item4.enabledStatus = 2;
                                done.Add(item3);
                            }
                        }
                    }
                }
            }
        }
Example #6
0
        private void SelectionChanged(int[] selectedIDs)
        {
            this.m_Selection = new List <PackageImportTreeView.PackageImportTreeViewItem>();
            using (List <TreeViewItem> .Enumerator enumerator = this.m_TreeView.data.GetRows().GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    TreeViewItem current = enumerator.Current;
                    if (((IEnumerable <int>)selectedIDs).Contains <int>(current.id))
                    {
                        PackageImportTreeView.PackageImportTreeViewItem importTreeViewItem = current as PackageImportTreeView.PackageImportTreeViewItem;
                        if (importTreeViewItem != null)
                        {
                            this.m_Selection.Add(importTreeViewItem);
                        }
                    }
                }
            }
            ImportPackageItem importPackageItem = this.m_Selection[0].item;

            if (this.m_Selection.Count == 1 && importPackageItem != null && !string.IsNullOrEmpty(importPackageItem.previewPath))
            {
                (this.m_TreeView.gui as PackageImportTreeView.PackageImportTreeViewGUI).showPreviewForID = this.m_Selection[0].id;
            }
            else
            {
                PopupWindowWithoutFocus.Hide();
            }
        }
        private PackageImportTreeView.EnabledState GetFolderChildrenEnabledState(PackageImportTreeView.PackageImportTreeViewItem folder)
        {
            ImportPackageItem item = folder.item;

            if (item != null && !item.isFolder)
            {
                Debug.LogError("Should be a folder item!");
            }
            if (!folder.hasChildren)
            {
                return(PackageImportTreeView.EnabledState.None);
            }
            PackageImportTreeView.EnabledState enabledState = PackageImportTreeView.EnabledState.NotSet;
            PackageImportTreeView.PackageImportTreeViewItem packageImportTreeViewItem = folder.children[0] as PackageImportTreeView.PackageImportTreeViewItem;
            ImportPackageItem item2 = packageImportTreeViewItem.item;
            int num = (item2 != null) ? item2.enabledStatus : 1;

            for (int i = 1; i < folder.children.Count; i++)
            {
                item2 = (folder.children[i] as PackageImportTreeView.PackageImportTreeViewItem).item;
                if (num != item2.enabledStatus)
                {
                    enabledState = PackageImportTreeView.EnabledState.Mixed;
                    break;
                }
            }
            if (enabledState == PackageImportTreeView.EnabledState.NotSet)
            {
                enabledState = ((num != 1) ? PackageImportTreeView.EnabledState.None : PackageImportTreeView.EnabledState.All);
            }
            return(enabledState);
        }
        private void RecursiveComputeEnabledStateForFolders(PackageImportTreeView.PackageImportTreeViewItem pitem, HashSet <PackageImportTreeView.PackageImportTreeViewItem> done)
        {
            ImportPackageItem item = pitem.item;

            if (item != null && !item.isFolder)
            {
                return;
            }
            if (pitem.hasChildren)
            {
                foreach (TreeViewItem current in pitem.children)
                {
                    this.RecursiveComputeEnabledStateForFolders(current as PackageImportTreeView.PackageImportTreeViewItem, done);
                }
            }
            if (item != null && !done.Contains(pitem))
            {
                PackageImportTreeView.EnabledState folderChildrenEnabledState = this.GetFolderChildrenEnabledState(pitem);
                item.enabledStatus = (int)folderChildrenEnabledState;
                if (folderChildrenEnabledState == PackageImportTreeView.EnabledState.Mixed)
                {
                    done.Add(pitem);
                    for (PackageImportTreeView.PackageImportTreeViewItem packageImportTreeViewItem = pitem.parent as PackageImportTreeView.PackageImportTreeViewItem; packageImportTreeViewItem != null; packageImportTreeViewItem = (packageImportTreeViewItem.parent as PackageImportTreeView.PackageImportTreeViewItem))
                    {
                        ImportPackageItem item2 = packageImportTreeViewItem.item;
                        if (item2 != null && !done.Contains(packageImportTreeViewItem))
                        {
                            item2.enabledStatus = 2;
                            done.Add(packageImportTreeViewItem);
                        }
                    }
                }
            }
        }
Example #9
0
            private void DoPreviewPopup(PackageImportTreeView.PackageImportTreeViewItem pitem, Rect rowRect)
            {
                ImportPackageItem importPackageItem = pitem.item;

                if (importPackageItem == null)
                {
                    return;
                }
                if (Event.current.type == EventType.MouseDown && rowRect.Contains(Event.current.mousePosition) && !PopupWindowWithoutFocus.IsVisible())
                {
                    this.showPreviewForID = pitem.id;
                }
                if (pitem.id != this.showPreviewForID || Event.current.type == EventType.Layout)
                {
                    return;
                }
                this.showPreviewForID = 0;
                if (string.IsNullOrEmpty(importPackageItem.previewPath))
                {
                    return;
                }
                Texture2D preview       = PackageImport.GetPreview(importPackageItem.previewPath);
                Rect      activatorRect = rowRect;

                activatorRect.width = EditorGUIUtility.currentViewWidth;
                PopupWindowWithoutFocus.Show(activatorRect, (PopupWindowContent) new PackageImportTreeView.PreviewPopup(preview), new PopupLocationHelper.PopupLocation[3]
                {
                    PopupLocationHelper.PopupLocation.Right,
                    PopupLocationHelper.PopupLocation.Left,
                    PopupLocationHelper.PopupLocation.Below
                });
            }
Example #10
0
            private void DoPreviewPopup(PackageImportTreeView.PackageImportTreeViewItem pitem, Rect rowRect)
            {
                ImportPackageItem item = pitem.item;

                if (item != null)
                {
                    if (Event.current.type == EventType.MouseDown && rowRect.Contains(Event.current.mousePosition) && !PopupWindowWithoutFocus.IsVisible())
                    {
                        this.showPreviewForID = pitem.id;
                    }
                    if (pitem.id == this.showPreviewForID && Event.current.type != EventType.Layout)
                    {
                        this.showPreviewForID = 0;
                        if (!string.IsNullOrEmpty(item.previewPath))
                        {
                            Texture2D preview = PackageImport.GetPreview(item.previewPath);
                            Rect      rect    = rowRect;
                            rect.width = EditorGUIUtility.currentViewWidth;
                            Rect arg_AF_0 = rect;
                            PopupWindowContent arg_AF_1 = new PackageImportTreeView.PreviewPopup(preview);
                            PopupLocationHelper.PopupLocation[] expr_A7 = new PopupLocationHelper.PopupLocation[3];
                            expr_A7[0] = PopupLocationHelper.PopupLocation.Right;
                            expr_A7[1] = PopupLocationHelper.PopupLocation.Left;
                            PopupWindowWithoutFocus.Show(arg_AF_0, arg_AF_1, expr_A7);
                        }
                    }
                }
            }
Example #11
0
            public override void OnRowGUI(Rect rowRect, TreeViewItem tvItem, int row, bool selected, bool focused)
            {
                this.k_IndentWidth  = 18f;
                this.k_FoldoutWidth = 18f;
                PackageImportTreeView.PackageImportTreeViewItem pitem = tvItem as PackageImportTreeView.PackageImportTreeViewItem;
                ImportPackageItem importPackageItem = pitem.item;
                bool flag1 = Event.current.type == EventType.Repaint;

                if (selected && flag1)
                {
                    TreeViewGUI.s_Styles.selectionStyle.Draw(rowRect, false, false, true, focused);
                }
                bool flag2       = importPackageItem != null;
                bool flag3       = importPackageItem == null || importPackageItem.isFolder;
                bool flag4       = importPackageItem != null && importPackageItem.assetChanged;
                bool flag5       = importPackageItem != null && importPackageItem.pathConflict;
                bool flag6       = importPackageItem == null || importPackageItem.exists;
                bool flag7       = importPackageItem != null && importPackageItem.projectAsset;
                bool doReInstall = this.m_PackageImportView.doReInstall;

                if (this.m_TreeView.data.IsExpandable(tvItem))
                {
                    this.DoFoldout(rowRect, tvItem, row);
                }
                Rect toggleRect = new Rect(this.k_BaseIndent + (float)tvItem.depth * this.indentWidth + this.k_FoldoutWidth, rowRect.y, 18f, rowRect.height);

                if (flag3 && !flag7 || flag2 && !flag7 && (flag4 || doReInstall))
                {
                    this.DoToggle(pitem, toggleRect);
                }
                EditorGUI.BeginDisabledGroup(!flag2 || flag7);
                Rect contentRect = new Rect(toggleRect.xMax, rowRect.y, rowRect.width, rowRect.height);

                this.DoIconAndText(tvItem, contentRect, selected, focused);
                this.DoPreviewPopup(pitem, rowRect);
                if (flag1 && flag2 && flag5)
                {
                    Rect position = new Rect(rowRect.xMax - 58f, rowRect.y, rowRect.height, rowRect.height);
                    EditorGUIUtility.SetIconSize(new Vector2(rowRect.height, rowRect.height));
                    GUI.Label(position, PackageImportTreeView.PackageImportTreeViewGUI.Constants.badgeWarn);
                    EditorGUIUtility.SetIconSize(Vector2.zero);
                }
                if (flag1 && flag2 && (!flag6 && !flag5))
                {
                    Texture image = PackageImportTreeView.PackageImportTreeViewGUI.Constants.badgeNew.image;
                    GUI.Label(new Rect((float)((double)rowRect.xMax - (double)image.width - 6.0), rowRect.y + (float)(((double)rowRect.height - (double)image.height) / 2.0), (float)image.width, (float)image.height), PackageImportTreeView.PackageImportTreeViewGUI.Constants.badgeNew, PackageImportTreeView.PackageImportTreeViewGUI.Constants.paddinglessStyle);
                }
                if (flag1 && doReInstall && flag7)
                {
                    Texture image = PackageImportTreeView.PackageImportTreeViewGUI.Constants.badgeDelete.image;
                    GUI.Label(new Rect((float)((double)rowRect.xMax - (double)image.width - 6.0), rowRect.y + (float)(((double)rowRect.height - (double)image.height) / 2.0), (float)image.width, (float)image.height), PackageImportTreeView.PackageImportTreeViewGUI.Constants.badgeDelete, PackageImportTreeView.PackageImportTreeViewGUI.Constants.paddinglessStyle);
                }
                if (flag1 && flag2 && (flag6 || flag5) && flag4)
                {
                    Texture image = PackageImportTreeView.PackageImportTreeViewGUI.Constants.badgeChange.image;
                    GUI.Label(new Rect((float)((double)rowRect.xMax - (double)image.width - 6.0), rowRect.y, rowRect.height, rowRect.height), PackageImportTreeView.PackageImportTreeViewGUI.Constants.badgeChange, PackageImportTreeView.PackageImportTreeViewGUI.Constants.paddinglessStyle);
                }
                EditorGUI.EndDisabledGroup();
            }
 public PackageImportTreeViewItem(ImportPackageItem itemIn, int id, int depth, TreeViewItem parent, string displayName) : base(id, depth, parent, displayName)
 {
     this.item = itemIn;
     if (this.item == null)
     {
         this.m_EnableState = PackageImportTreeView.EnabledState.All;
     }
     else
     {
         this.m_EnableState = (PackageImportTreeView.EnabledState) this.item.enabledStatus;
     }
 }
Example #13
0
        private bool ItemShouldBeConsideredForEnabledCheck(PackageImportTreeView.PackageImportTreeViewItem pitem)
        {
            if (pitem == null)
            {
                return(false);
            }
            if (pitem.item == null)
            {
                return(true);
            }
            ImportPackageItem importPackageItem = pitem.item;

            return(!importPackageItem.projectAsset && (importPackageItem.isFolder || importPackageItem.assetChanged || this.doReInstall));
        }
Example #14
0
            protected override Texture GetIconForNode(TreeViewItem tvItem)
            {
                ImportPackageItem importPackageItem = (tvItem as PackageImportTreeView.PackageImportTreeViewItem).item;

                if (importPackageItem == null || importPackageItem.isFolder)
                {
                    return((Texture)PackageImportTreeView.PackageImportTreeViewGUI.Constants.folderIcon);
                }
                Texture cachedIcon = AssetDatabase.GetCachedIcon(importPackageItem.destinationAssetPath);

                if ((UnityEngine.Object)cachedIcon != (UnityEngine.Object)null)
                {
                    return(cachedIcon);
                }
                return((Texture)InternalEditorUtility.GetIconForFile(importPackageItem.destinationAssetPath));
            }
 private bool ItemShouldBeConsideredForEnabledCheck(PackageImportTreeViewItem pitem)
 {
     if (pitem == null)
     {
         return(false);
     }
     if (pitem.item != null)
     {
         ImportPackageItem item = pitem.item;
         if (item.projectAsset || ((!item.isFolder && !item.assetChanged) && !this.doReInstall))
         {
             return(false);
         }
     }
     return(true);
 }
 private void EnableChildrenRecursive(TreeViewItem parentItem, int enabled)
 {
     if (parentItem.hasChildren)
     {
         foreach (TreeViewItem item in parentItem.children)
         {
             PackageImportTreeViewItem item2 = item as PackageImportTreeViewItem;
             ImportPackageItem         item3 = item2.item;
             if (item3 != null)
             {
                 item3.enabledStatus = enabled;
             }
             this.EnableChildrenRecursive(item2, enabled);
         }
     }
 }
 private void EnableChildrenRecursive(TreeViewItem parentItem, int enabled)
 {
     if (!parentItem.hasChildren)
     {
         return;
     }
     foreach (TreeViewItem current in parentItem.children)
     {
         PackageImportTreeView.PackageImportTreeViewItem packageImportTreeViewItem = current as PackageImportTreeView.PackageImportTreeViewItem;
         ImportPackageItem item = packageImportTreeViewItem.item;
         if (item != null)
         {
             item.enabledStatus = enabled;
         }
         this.EnableChildrenRecursive(packageImportTreeViewItem, enabled);
     }
 }
            protected override Texture GetIconForNode(TreeViewItem tvItem)
            {
                PackageImportTreeView.PackageImportTreeViewItem item = tvItem as PackageImportTreeView.PackageImportTreeViewItem;
                ImportPackageItem item2 = item.item;

                if ((item2 == null) || item2.isFolder)
                {
                    return(Constants.folderIcon);
                }
                Texture cachedIcon = AssetDatabase.GetCachedIcon(item2.destinationAssetPath);

                if (cachedIcon != null)
                {
                    return(cachedIcon);
                }
                return(InternalEditorUtility.GetIconForFile(item2.destinationAssetPath));
            }
Example #19
0
 private static bool IsAllFilePathsValid(ImportPackageItem[] assetItems, out string errorMessage)
 {
     for (int i = 0; i < assetItems.Length; i++)
     {
         ImportPackageItem importPackageItem = assetItems[i];
         if (!importPackageItem.isFolder)
         {
             char c;
             int  num;
             if (PackageImport.HasInvalidCharInFilePath(importPackageItem.destinationAssetPath, out c, out num))
             {
                 errorMessage = string.Format("Invalid character found in file path: '{0}'. Invalid ascii value: {1} (at character index {2}).", importPackageItem.destinationAssetPath, (int)c, num);
                 return(false);
             }
         }
     }
     errorMessage = string.Empty;
     return(true);
 }
            private static void Toggle(ImportPackageItem[] items, PackageImportTreeView.PackageImportTreeViewItem pitem, Rect toggleRect)
            {
                ImportPackageItem item = pitem.item;

                if (item != null)
                {
                    bool     flag   = item.enabledStatus > 0;
                    GUIStyle toggle = EditorStyles.toggle;
                    if (item.isFolder && (item.enabledStatus == 2))
                    {
                        toggle = EditorStyles.toggleMixed;
                    }
                    bool flag3 = GUI.Toggle(toggleRect, flag, GUIContent.none, toggle);
                    if (flag3 != flag)
                    {
                        item.enabledStatus = !flag3 ? 0 : 1;
                    }
                }
            }
        private bool ItemShouldBeConsideredForEnabledCheck(PackageImportTreeView.PackageImportTreeViewItem pitem)
        {
            bool result;

            if (pitem == null)
            {
                result = false;
            }
            else if (pitem.item == null)
            {
                result = true;
            }
            else
            {
                ImportPackageItem item = pitem.item;
                result = (!item.projectAsset && (item.isFolder || item.assetChanged || this.doReInstall));
            }
            return(result);
        }
            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;

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

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

                for (int i = 0; i < packageItems.Length; i++)
                {
                    ImportPackageItem itemIn = packageItems[i];
                    if (!PackageImport.HasInvalidCharInFilePath(itemIn.destinationAssetPath))
                    {
                        string       fileName      = Path.GetFileName(itemIn.destinationAssetPath);
                        string       directoryName = Path.GetDirectoryName(itemIn.destinationAssetPath);
                        TreeViewItem parent        = this.EnsureFolderPath(directoryName, treeViewFolders, initExpandedState);
                        if (parent != null)
                        {
                            int hashCode = itemIn.destinationAssetPath.GetHashCode();
                            PackageImportTreeView.PackageImportTreeViewItem child = new PackageImportTreeView.PackageImportTreeViewItem(itemIn, hashCode, parent.depth + 1, parent, fileName);
                            parent.AddChild(child);
                            if (initExpandedState)
                            {
                                base.m_TreeView.state.expandedIDs.Add(hashCode);
                            }
                            if (itemIn.isFolder)
                            {
                                treeViewFolders[itemIn.destinationAssetPath] = child;
                            }
                        }
                    }
                }
                if (initExpandedState)
                {
                    base.m_TreeView.state.expandedIDs.Sort();
                }
            }
        private void ItemWasToggled(PackageImportTreeViewItem pitem)
        {
            ImportPackageItem item = pitem.item;

            if (item != null)
            {
                if (this.m_Selection.Count <= 1)
                {
                    this.EnableChildrenRecursive(pitem, item.enabledStatus);
                }
                else
                {
                    foreach (PackageImportTreeViewItem item2 in this.m_Selection)
                    {
                        item2.item.enabledStatus = item.enabledStatus;
                    }
                }
                this.ComputeEnabledStateForFolders();
            }
        }
Example #25
0
            public override void FetchData()
            {
                this.m_RootItem = (TreeViewItem) new PackageImportTreeView.PackageImportTreeViewItem((ImportPackageItem)null, "Assets".GetHashCode(), -1, (TreeViewItem)null, "InvisibleAssetsFolder");
                bool initExpandedState = true;

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

                for (int index = 0; index < packageItems.Length; ++index)
                {
                    ImportPackageItem itemIn = packageItems[index];
                    if (!PackageImport.HasInvalidCharInFilePath(itemIn.destinationAssetPath))
                    {
                        string       fileName = Path.GetFileName(itemIn.destinationAssetPath);
                        TreeViewItem parent   = this.EnsureFolderPath(Path.GetDirectoryName(itemIn.destinationAssetPath), treeViewFolders, initExpandedState);
                        if (parent != null)
                        {
                            int hashCode = itemIn.destinationAssetPath.GetHashCode();
                            PackageImportTreeView.PackageImportTreeViewItem importTreeViewItem = new PackageImportTreeView.PackageImportTreeViewItem(itemIn, hashCode, parent.depth + 1, parent, fileName);
                            parent.AddChild((TreeViewItem)importTreeViewItem);
                            if (initExpandedState)
                            {
                                this.m_TreeView.state.expandedIDs.Add(hashCode);
                            }
                            if (itemIn.isFolder)
                            {
                                treeViewFolders[itemIn.destinationAssetPath] = importTreeViewItem;
                            }
                        }
                    }
                }
                if (!initExpandedState)
                {
                    return;
                }
                this.m_TreeView.state.expandedIDs.Sort();
            }
        public void OnGUI(Rect rect)
        {
            if (Event.current.type == EventType.ScrollWheel)
            {
                PopupWindowWithoutFocus.Hide();
            }
            int controlID = GUIUtility.GetControlID(FocusType.Keyboard);

            this.m_TreeView.OnGUI(rect, controlID);
            if ((((Event.current.type == EventType.KeyDown) && (Event.current.keyCode == KeyCode.Space)) && ((this.m_Selection != null) && (this.m_Selection.Count > 0))) && (GUIUtility.keyboardControl == controlID))
            {
                ImportPackageItem item = this.m_Selection[0].item;
                if (item != null)
                {
                    int num2 = (item.enabledStatus != 0) ? 0 : 1;
                    item.enabledStatus = num2;
                    this.ItemWasToggled(this.m_Selection[0]);
                }
                Event.current.Use();
            }
        }
            protected override Texture GetIconForItem(TreeViewItem tvItem)
            {
                PackageImportTreeView.PackageImportTreeViewItem packageImportTreeViewItem = tvItem as PackageImportTreeView.PackageImportTreeViewItem;
                ImportPackageItem item = packageImportTreeViewItem.item;
                Texture           result;

                if (item == null || item.isFolder)
                {
                    result = PackageImportTreeView.PackageImportTreeViewGUI.Constants.folderIcon;
                }
                else
                {
                    Texture cachedIcon = AssetDatabase.GetCachedIcon(item.destinationAssetPath);
                    if (cachedIcon != null)
                    {
                        result = cachedIcon;
                    }
                    else
                    {
                        result = InternalEditorUtility.GetIconForFile(item.destinationAssetPath);
                    }
                }
                return(result);
            }
 public PackageImportTreeViewItem(ImportPackageItem itemIn, int id, int depth, TreeViewItem parent, string displayName)
   : base(id, depth, parent, displayName)
 {
   this.item = itemIn;
   if (this.item == null)
     this.m_EnableState = PackageImportTreeView.EnabledState.All;
   else
     this.m_EnableState = (PackageImportTreeView.EnabledState) this.item.enabledStatus;
 }
 private bool ShowTreeGUI(bool reInstalling, ImportPackageItem[] items)
 {
   if (reInstalling)
     return true;
   if (items.Length == 0)
     return false;
   for (int index = 0; index < items.Length; ++index)
   {
     if (!items[index].isFolder && items[index].assetChanged)
       return true;
   }
   return false;
 }
 public PackageImportTreeViewItem(ImportPackageItem itemIn, int id, int depth, TreeViewItem parent, string displayName) : base(id, depth, parent, displayName)
 {
     this.item = itemIn;
 }
 private static bool ValidateInput(ImportPackageItem[] items)
 {
   string errorMessage;
   if (!PackageImport.IsAllFilePathsValid(items, out errorMessage))
     return EditorUtility.DisplayDialog("Invalid file path found", errorMessage + "\nDo you want to import the valid file paths of the package or cancel importing?", "Import", "Cancel importing");
   return true;
 }
            public override void OnRowGUI(Rect rowRect, TreeViewItem tvItem, int row, bool selected, bool focused)
            {
                base.k_IndentWidth  = 18f;
                base.k_FoldoutWidth = 18f;
                PackageImportTreeView.PackageImportTreeViewItem pitem = tvItem as PackageImportTreeView.PackageImportTreeViewItem;
                ImportPackageItem item = pitem.item;
                bool flag = Event.current.type == EventType.Repaint;

                if (selected && flag)
                {
                    TreeViewGUI.s_Styles.selectionStyle.Draw(rowRect, false, false, true, focused);
                }
                bool flag2       = item != null;
                bool flag3       = (item == null) || item.isFolder;
                bool flag4       = (item != null) && item.assetChanged;
                bool flag5       = (item != null) && item.pathConflict;
                bool flag6       = (item == null) || item.exists;
                bool flag7       = (item != null) && item.projectAsset;
                bool doReInstall = this.m_PackageImportView.doReInstall;

                if (base.m_TreeView.data.IsExpandable(tvItem))
                {
                    this.DoFoldout(rowRect, tvItem, row);
                }
                EditorGUI.BeginDisabledGroup(!flag2 || flag7);
                Rect toggleRect = new Rect((base.k_BaseIndent + (tvItem.depth * base.indentWidth)) + base.k_FoldoutWidth, rowRect.y, 18f, rowRect.height);

                if ((flag2 && !flag7) && ((flag3 || flag4) || doReInstall))
                {
                    this.DoToggle(pitem, toggleRect);
                }
                Rect contentRect = new Rect(toggleRect.xMax, rowRect.y, rowRect.width, rowRect.height);

                this.DoIconAndText(tvItem, contentRect, selected, focused);
                this.DoPreviewPopup(pitem, rowRect);
                if ((flag && flag2) && flag5)
                {
                    Rect position = new Rect(rowRect.xMax - 58f, rowRect.y, rowRect.height, rowRect.height);
                    EditorGUIUtility.SetIconSize(new Vector2(rowRect.height, rowRect.height));
                    GUI.Label(position, Constants.badgeWarn);
                    EditorGUIUtility.SetIconSize(Vector2.zero);
                }
                if ((flag && flag2) && (!flag6 && !flag5))
                {
                    Texture image = Constants.badgeNew.image;
                    Rect    rect4 = new Rect((rowRect.xMax - image.width) - 6f, rowRect.y + ((rowRect.height - image.height) / 2f), (float)image.width, (float)image.height);
                    GUI.Label(rect4, Constants.badgeNew, Constants.paddinglessStyle);
                }
                if ((flag && doReInstall) && flag7)
                {
                    Texture texture2 = Constants.badgeDelete.image;
                    Rect    rect5    = new Rect((rowRect.xMax - texture2.width) - 6f, rowRect.y + ((rowRect.height - texture2.height) / 2f), (float)texture2.width, (float)texture2.height);
                    GUI.Label(rect5, Constants.badgeDelete, Constants.paddinglessStyle);
                }
                if (((flag && flag2) && (flag6 || flag5)) && flag4)
                {
                    Texture texture3 = Constants.badgeChange.image;
                    Rect    rect6    = new Rect((rowRect.xMax - texture3.width) - 6f, rowRect.y, rowRect.height, rowRect.height);
                    GUI.Label(rect6, Constants.badgeChange, Constants.paddinglessStyle);
                }
                EditorGUI.EndDisabledGroup();
            }
 private static bool IsAllFilePathsValid(ImportPackageItem[] assetItems, out string errorMessage)
 {
   foreach (ImportPackageItem assetItem in assetItems)
   {
     char invalidChar;
     int invalidCharIndex;
     if (!assetItem.isFolder && PackageImport.HasInvalidCharInFilePath(assetItem.destinationAssetPath, out invalidChar, out invalidCharIndex))
     {
       errorMessage = string.Format("Invalid character found in file path: '{0}'. Invalid ascii value: {1} (at character index {2}).", (object) assetItem.destinationAssetPath, (object) (int) invalidChar, (object) invalidCharIndex);
       return false;
     }
   }
   errorMessage = string.Empty;
   return true;
 }
 public static void ShowImportPackage(string packagePath, ImportPackageItem[] items, string packageIconPath, bool allowReInstall)
 {
   if (!PackageImport.ValidateInput(items))
     return;
   EditorWindow.GetWindow<PackageImport>(true, "Import Unity Package").Init(packagePath, items, packageIconPath, allowReInstall);
 }
 private void Init(string packagePath, ImportPackageItem[] items, string packageIconPath, bool allowReInstall)
 {
   this.DestroyCreatedIcons();
   this.m_ShowReInstall = allowReInstall;
   this.m_ReInstallPackage = true;
   this.m_TreeViewState = (TreeViewState) null;
   this.m_Tree = (PackageImportTreeView) null;
   this.m_ImportPackageItems = items;
   this.m_PackageName = Path.GetFileNameWithoutExtension(packagePath);
   this.m_PackageIconPath = packageIconPath;
   this.Repaint();
 }
 public static extern void ImportPackageAssets(ImportPackageItem[] items, bool performReInstall);
 public static extern void ImportPackageAssetsImmediately(string packageName, ImportPackageItem[] items, bool performReInstall);
 private static void Toggle(ImportPackageItem[] items, PackageImportTreeView.PackageImportTreeViewItem pitem, Rect toggleRect)
 {
   bool flag1 = pitem.enableState > PackageImportTreeView.EnabledState.None;
   bool flag2 = pitem.item == null || pitem.item.isFolder;
   GUIStyle style = EditorStyles.toggle;
   if (flag2 && pitem.enableState == PackageImportTreeView.EnabledState.Mixed)
     style = EditorStyles.toggleMixed;
   bool flag3 = GUI.Toggle(toggleRect, flag1, GUIContent.none, style);
   if (flag3 == flag1)
     return;
   pitem.enableState = !flag3 ? PackageImportTreeView.EnabledState.None : PackageImportTreeView.EnabledState.All;
 }