public override void FetchData()
        {
            int depth = 0;

            base.m_RootItem = new TreeViewItem(this.m_RootInstanceID, depth, null, CreateDisplayName(this.m_RootInstanceID));
            if (!base.showRootNode)
            {
                this.SetExpanded(base.m_RootItem, true);
            }
            IHierarchyProperty property = new HierarchyProperty(HierarchyType.Assets);

            property.Reset();
            if (!property.Find(this.m_RootInstanceID, null))
            {
                Debug.LogError("Root Asset with id " + this.m_RootInstanceID + " not found!!");
            }
            int minDepth = property.depth + (!base.showRootNode ? 1 : 0);

            int[]     expanded = base.expandedIDs.ToArray();
            Texture2D textured = EditorGUIUtility.FindTexture(EditorResourcesUtility.emptyFolderIconName);

            base.m_VisibleRows = new List <TreeViewItem>();
            while (property.NextWithDepthCheck(expanded, minDepth))
            {
                if (!this.foldersOnly || property.isFolder)
                {
                    TreeViewItem item;
                    depth = property.depth - minDepth;
                    if (property.isFolder)
                    {
                        item = new FolderTreeItem(property.instanceID, depth, null, property.name);
                    }
                    else
                    {
                        item = new NonFolderTreeItem(property.instanceID, depth, null, property.name);
                    }
                    if (property.isFolder && !property.hasChildren)
                    {
                        item.icon = textured;
                    }
                    else
                    {
                        item.icon = property.icon;
                    }
                    if (property.hasChildren)
                    {
                        item.AddChild(null);
                    }
                    base.m_VisibleRows.Add(item);
                }
            }
            TreeViewUtility.SetChildParentReferences(base.m_VisibleRows, base.m_RootItem);
            if (this.foldersFirst)
            {
                FoldersFirstRecursive(base.m_RootItem);
                base.m_VisibleRows.Clear();
                base.GetVisibleItemsRecursive(base.m_RootItem, base.m_VisibleRows);
            }
            base.m_NeedRefreshVisibleFolders = false;
            bool revealSelectionAndFrameLastSelected = false;

            base.m_TreeView.SetSelection(Selection.instanceIDs, revealSelectionAndFrameLastSelected);
        }
        public void DoDeletedItemsGUI(ASHistoryWindow parentWin, Rect theRect, GUIStyle s, float offset, float endOffset, bool focused)
        {
            Event     current = Event.current;
            Texture2D texture = EditorGUIUtility.FindTexture(EditorResourcesUtility.folderIconName);

            offset += 3f;
            Rect position1 = new Rect(this.m_Indent, offset, theRect.width - this.m_Indent, ASHistoryFileView.m_RowHeight);

            if (current.type == EventType.MouseDown && position1.Contains(current.mousePosition))
            {
                GUIUtility.keyboardControl = this.m_FileViewControlID;
                this.SelType = ASHistoryFileView.SelectionType.DeletedItemsRoot;
                this.ScrollToDeletedItem(-1);
                parentWin.DoLocalSelectionChange();
            }
            position1.width -= position1.x;
            position1.x      = 0.0f;
            GUIContent content = new GUIContent("Deleted Assets");

            content.image = (Texture)texture;
            int baseIndent = (int)this.m_BaseIndent;

            s.padding.left = baseIndent;
            if (current.type == EventType.Repaint)
            {
                s.Draw(position1, content, false, false, this.SelType == ASHistoryFileView.SelectionType.DeletedItemsRoot, focused);
            }
            Rect position2 = new Rect(this.m_BaseIndent - this.m_FoldoutSize, offset, this.m_FoldoutSize, ASHistoryFileView.m_RowHeight);

            if (!this.m_DeletedItemsInitialized || this.m_DelPVstate.lv.totalRows != 0)
            {
                this.DeletedItemsToggle = GUI.Toggle(position2, this.DeletedItemsToggle, GUIContent.none, ASHistoryFileView.ms_Styles.foldout);
            }
            offset += ASHistoryFileView.m_RowHeight;
            if (!this.DeletedItemsToggle)
            {
                return;
            }
            int row     = this.m_DelPVstate.lv.row;
            int index1  = 0;
            int folder1 = -1;
            int file    = -1;
            int index2  = 0;

            while ((double)offset <= (double)endOffset && index2 < this.m_DelPVstate.lv.totalRows)
            {
                if ((double)offset + (double)ASHistoryFileView.m_RowHeight >= 0.0)
                {
                    if (folder1 == -1)
                    {
                        this.m_DelPVstate.IndexToFolderAndFile(index2, ref folder1, ref file);
                    }
                    position1 = new Rect(0.0f, offset, (float)Screen.width, ASHistoryFileView.m_RowHeight);
                    ParentViewFolder folder2 = this.m_DelPVstate.folders[folder1];
                    if (current.type == EventType.MouseDown && position1.Contains(current.mousePosition))
                    {
                        if (current.button != 1 || this.SelType != ASHistoryFileView.SelectionType.DeletedItems || !this.m_DelPVstate.selectedItems[index1])
                        {
                            GUIUtility.keyboardControl = this.m_FileViewControlID;
                            this.SelType             = ASHistoryFileView.SelectionType.DeletedItems;
                            this.m_DelPVstate.lv.row = index1;
                            ListViewShared.MultiSelection((ListViewShared.InternalListViewState)null, row, this.m_DelPVstate.lv.row, ref this.m_DelPVstate.initialSelectedItem, ref this.m_DelPVstate.selectedItems);
                            this.ScrollToDeletedItem(index1);
                            parentWin.DoLocalSelectionChange();
                        }
                        if (current.button == 1 && this.SelType == ASHistoryFileView.SelectionType.DeletedItems)
                        {
                            GUIUtility.hotControl = 0;
                            EditorUtility.DisplayCustomMenu(new Rect(current.mousePosition.x, current.mousePosition.y, 1f, 1f), this.dropDownMenuItems, -1, new EditorUtility.SelectMenuItemFunction(this.ContextMenuClick), (object)null);
                        }
                        Event.current.Use();
                    }
                    int num;
                    if (file != -1)
                    {
                        content.text  = folder2.files[file].name;
                        content.image = (Texture)InternalEditorUtility.GetIconForFile(folder2.files[file].name);
                        num           = (int)((double)this.m_BaseIndent + (double)this.m_Indent * 2.0);
                    }
                    else
                    {
                        content.text  = folder2.name;
                        content.image = (Texture)texture;
                        num           = (int)((double)this.m_BaseIndent + (double)this.m_Indent);
                    }
                    s.padding.left = num;
                    if (Event.current.type == EventType.Repaint)
                    {
                        s.Draw(position1, content, false, false, this.m_DelPVstate.selectedItems[index1], focused);
                    }
                    this.m_DelPVstate.NextFileFolder(ref folder1, ref file);
                    ++index1;
                }
                ++index2;
                offset += ASHistoryFileView.m_RowHeight;
            }
        }
        public void DoGUI(ASHistoryWindow parentWin, Rect theRect, bool focused)
        {
            if (ASHistoryFileView.ms_Styles == null)
            {
                ASHistoryFileView.ms_Styles = new ASHistoryFileView.Styles();
            }
            this.m_ScreenRect = theRect;
            Hashtable hashtable = new Hashtable();

            foreach (UnityEngine.Object @object in Selection.objects)
            {
                hashtable.Add((object)@object.GetInstanceID(), (object)null);
            }
            this.m_FileViewControlID = GUIUtility.GetControlID(ASHistoryFileView.ms_FileViewHash, FocusType.Native);
            this.KeyboardGUI(parentWin);
            focused &= GUIUtility.keyboardControl == this.m_FileViewControlID;
            HierarchyProperty property = new HierarchyProperty(HierarchyType.Assets);
            int  num1     = property.CountRemaining(this.m_ExpandedArray);
            int  num2     = !this.DeletedItemsToggle ? 0 : this.m_DelPVstate.lv.totalRows;
            Rect viewRect = new Rect(0.0f, 0.0f, 1f, (float)((double)(num1 + 2 + num2) * (double)ASHistoryFileView.m_RowHeight + 16.0));

            this.m_ScrollPosition = GUI.BeginScrollView(this.m_ScreenRect, this.m_ScrollPosition, viewRect);
            theRect.width         = (double)viewRect.height <= (double)this.m_ScreenRect.height ? theRect.width : theRect.width - 18f;
            int count = Mathf.RoundToInt(this.m_ScrollPosition.y - 6f - ASHistoryFileView.m_RowHeight) / Mathf.RoundToInt(ASHistoryFileView.m_RowHeight);

            if (count > num1)
            {
                count = num1;
            }
            else if (count < 0)
            {
                count = 0;
                this.m_ScrollPosition.y = 0.0f;
            }
            GUIContent guiContent = new GUIContent();
            Event      current    = Event.current;
            GUIStyle   s          = new GUIStyle(ASHistoryFileView.ms_Styles.label);
            Texture2D  texture    = EditorGUIUtility.FindTexture(EditorResourcesUtility.folderIconName);
            float      y1         = (float)((double)count * (double)ASHistoryFileView.m_RowHeight + 3.0);
            float      endOffset  = this.m_ScreenRect.height + this.m_ScrollPosition.y;
            Rect       position   = new Rect(0.0f, y1, theRect.width, ASHistoryFileView.m_RowHeight);

            if (current.type == EventType.MouseDown && position.Contains(current.mousePosition))
            {
                this.SelType = ASHistoryFileView.SelectionType.All;
                GUIUtility.keyboardControl = this.m_FileViewControlID;
                this.ScrollTo(0.0f);
                parentWin.DoLocalSelectionChange();
                current.Use();
            }
            GUIContent content = new GUIContent("Entire Project");

            content.image = (Texture)texture;
            int baseIndent = (int)this.m_BaseIndent;

            s.padding.left = 3;
            if (Event.current.type == EventType.Repaint)
            {
                s.Draw(position, content, false, false, this.SelType == ASHistoryFileView.SelectionType.All, focused);
            }
            float y2 = y1 + (ASHistoryFileView.m_RowHeight + 3f);

            property.Reset();
            property.Skip(count, this.m_ExpandedArray);
            while (property.Next(this.m_ExpandedArray) && (double)y2 <= (double)endOffset)
            {
                int instanceId = property.instanceID;
                position = new Rect(0.0f, y2, theRect.width, ASHistoryFileView.m_RowHeight);
                if (Event.current.type == EventType.Repaint)
                {
                    content.text  = property.name;
                    content.image = (Texture)property.icon;
                    int num3 = (int)((double)this.m_BaseIndent + (double)this.m_Indent * (double)property.depth);
                    s.padding.left = num3;
                    bool on = hashtable.Contains((object)instanceId);
                    s.Draw(position, content, false, false, on, focused);
                }
                if (property.hasChildren)
                {
                    bool flag = property.IsExpanded(this.m_ExpandedArray);
                    GUI.changed = false;
                    bool expand = GUI.Toggle(new Rect(this.m_BaseIndent + this.m_Indent * (float)property.depth - this.m_FoldoutSize, y2, this.m_FoldoutSize, ASHistoryFileView.m_RowHeight), flag, GUIContent.none, ASHistoryFileView.ms_Styles.foldout);
                    if (GUI.changed)
                    {
                        if (Event.current.alt)
                        {
                            this.SetExpandedRecurse(instanceId, expand);
                        }
                        else
                        {
                            this.SetExpanded(instanceId, expand);
                        }
                    }
                }
                if (current.type == EventType.MouseDown && Event.current.button == 0 && position.Contains(Event.current.mousePosition))
                {
                    GUIUtility.keyboardControl = this.m_FileViewControlID;
                    if (Event.current.clickCount == 2)
                    {
                        AssetDatabase.OpenAsset(instanceId);
                        GUIUtility.ExitGUI();
                    }
                    else if (position.Contains(current.mousePosition))
                    {
                        this.SelectionClick(property);
                    }
                    current.Use();
                }
                y2 += ASHistoryFileView.m_RowHeight;
            }
            float offset = y2 + 3f;

            this.DoDeletedItemsGUI(parentWin, theRect, s, offset, endOffset, focused);
            GUI.EndScrollView();
            switch (current.type)
            {
            case EventType.MouseDown:
                if (current.button == 0 && this.m_ScreenRect.Contains(current.mousePosition))
                {
                    GUIUtility.hotControl = this.m_FileViewControlID;
                    current.Use();
                    break;
                }
                break;

            case EventType.MouseUp:
                if (GUIUtility.hotControl == this.m_FileViewControlID)
                {
                    if (this.m_ScreenRect.Contains(current.mousePosition))
                    {
                        Selection.activeObject = (UnityEngine.Object)null;
                    }
                    GUIUtility.hotControl = 0;
                    current.Use();
                    break;
                }
                break;
            }
            this.HandleFraming();
        }
Beispiel #4
0
        public void DoDeletedItemsGUI(ASHistoryWindow parentWin, Rect theRect, GUIStyle s, float offset, float endOffset, bool focused)
        {
            Event     current = Event.current;
            Texture2D image   = EditorGUIUtility.FindTexture(EditorResourcesUtility.folderIconName);

            offset += 3f;
            Rect position = new Rect(this.m_Indent, offset, theRect.width - this.m_Indent, ASHistoryFileView.m_RowHeight);

            if (current.type == EventType.MouseDown && position.Contains(current.mousePosition))
            {
                GUIUtility.keyboardControl = this.m_FileViewControlID;
                this.SelType = ASHistoryFileView.SelectionType.DeletedItemsRoot;
                this.ScrollToDeletedItem(-1);
                parentWin.DoLocalSelectionChange();
            }
            position.width -= position.x;
            position.x      = 0f;
            GUIContent gUIContent = new GUIContent("Deleted Assets");

            gUIContent.image = image;
            int left = (int)this.m_BaseIndent;

            s.padding.left = left;
            if (current.type == EventType.Repaint)
            {
                s.Draw(position, gUIContent, false, false, this.SelType == ASHistoryFileView.SelectionType.DeletedItemsRoot, focused);
            }
            Rect position2 = new Rect(this.m_BaseIndent - this.m_FoldoutSize, offset, this.m_FoldoutSize, ASHistoryFileView.m_RowHeight);

            if (!this.m_DeletedItemsInitialized || this.m_DelPVstate.lv.totalRows != 0)
            {
                this.DeletedItemsToggle = GUI.Toggle(position2, this.DeletedItemsToggle, GUIContent.none, ASHistoryFileView.ms_Styles.foldout);
            }
            offset += ASHistoryFileView.m_RowHeight;
            if (this.DeletedItemsToggle)
            {
                int row  = this.m_DelPVstate.lv.row;
                int num  = 0;
                int num2 = -1;
                int num3 = -1;
                int num4 = 0;
                while (offset <= endOffset && num4 < this.m_DelPVstate.lv.totalRows)
                {
                    if (offset + ASHistoryFileView.m_RowHeight >= 0f)
                    {
                        if (num2 == -1)
                        {
                            this.m_DelPVstate.IndexToFolderAndFile(num4, ref num2, ref num3);
                        }
                        position = new Rect(0f, offset, (float)Screen.width, ASHistoryFileView.m_RowHeight);
                        ParentViewFolder parentViewFolder = this.m_DelPVstate.folders[num2];
                        if (current.type == EventType.MouseDown && position.Contains(current.mousePosition))
                        {
                            if (current.button != 1 || this.SelType != ASHistoryFileView.SelectionType.DeletedItems || !this.m_DelPVstate.selectedItems[num])
                            {
                                GUIUtility.keyboardControl = this.m_FileViewControlID;
                                this.SelType             = ASHistoryFileView.SelectionType.DeletedItems;
                                this.m_DelPVstate.lv.row = num;
                                ListViewShared.MultiSelection(null, row, this.m_DelPVstate.lv.row, ref this.m_DelPVstate.initialSelectedItem, ref this.m_DelPVstate.selectedItems);
                                this.ScrollToDeletedItem(num);
                                parentWin.DoLocalSelectionChange();
                            }
                            if (current.button == 1 && this.SelType == ASHistoryFileView.SelectionType.DeletedItems)
                            {
                                GUIUtility.hotControl = 0;
                                Rect position3 = new Rect(current.mousePosition.x, current.mousePosition.y, 1f, 1f);
                                EditorUtility.DisplayCustomMenu(position3, this.dropDownMenuItems, -1, new EditorUtility.SelectMenuItemFunction(this.ContextMenuClick), null);
                            }
                            Event.current.Use();
                        }
                        if (num3 != -1)
                        {
                            gUIContent.text  = parentViewFolder.files[num3].name;
                            gUIContent.image = InternalEditorUtility.GetIconForFile(parentViewFolder.files[num3].name);
                            left             = (int)(this.m_BaseIndent + this.m_Indent * 2f);
                        }
                        else
                        {
                            gUIContent.text  = parentViewFolder.name;
                            gUIContent.image = image;
                            left             = (int)(this.m_BaseIndent + this.m_Indent);
                        }
                        s.padding.left = left;
                        if (Event.current.type == EventType.Repaint)
                        {
                            s.Draw(position, gUIContent, false, false, this.m_DelPVstate.selectedItems[num], focused);
                        }
                        this.m_DelPVstate.NextFileFolder(ref num2, ref num3);
                        num++;
                    }
                    num4++;
                    offset += ASHistoryFileView.m_RowHeight;
                }
            }
        }
        public override void FetchData()
        {
            int depth = 0;

            this.m_RootItem = new TreeViewItem(this.m_RootInstanceID, depth, null, AssetsTreeViewDataSource.CreateDisplayName(this.m_RootInstanceID));
            if (!base.showRootItem)
            {
                this.SetExpanded(this.m_RootItem, true);
            }
            HierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.Assets, false);

            hierarchyProperty.Reset();
            if (!hierarchyProperty.Find(this.m_RootInstanceID, null))
            {
                Debug.LogError("Root Asset with id " + this.m_RootInstanceID + " not found!!");
            }
            int num = hierarchyProperty.depth + ((!base.showRootItem) ? 1 : 0);

            int[]     expanded = base.expandedIDs.ToArray();
            Texture2D icon     = EditorGUIUtility.FindTexture(EditorResourcesUtility.emptyFolderIconName);

            this.m_Rows = new List <TreeViewItem>();
            while (hierarchyProperty.NextWithDepthCheck(expanded, num))
            {
                if (!this.foldersOnly || hierarchyProperty.isFolder)
                {
                    depth = hierarchyProperty.depth - num;
                    TreeViewItem treeViewItem;
                    if (hierarchyProperty.isFolder)
                    {
                        treeViewItem = new AssetsTreeViewDataSource.FolderTreeItem(hierarchyProperty.instanceID, depth, null, hierarchyProperty.name);
                    }
                    else
                    {
                        treeViewItem = new AssetsTreeViewDataSource.NonFolderTreeItem(hierarchyProperty.instanceID, depth, null, hierarchyProperty.name);
                    }
                    if (hierarchyProperty.isFolder && !hierarchyProperty.hasChildren)
                    {
                        treeViewItem.icon = icon;
                    }
                    else
                    {
                        treeViewItem.icon = hierarchyProperty.icon;
                    }
                    if (hierarchyProperty.hasChildren)
                    {
                        treeViewItem.AddChild(null);
                    }
                    this.m_Rows.Add(treeViewItem);
                }
            }
            TreeViewUtility.SetChildParentReferences(this.m_Rows, this.m_RootItem);
            if (this.foldersFirst)
            {
                AssetsTreeViewDataSource.FoldersFirstRecursive(this.m_RootItem);
                this.m_Rows.Clear();
                base.GetVisibleItemsRecursive(this.m_RootItem, this.m_Rows);
            }
            this.m_NeedRefreshRows = false;
            bool revealSelectionAndFrameLastSelected = false;

            this.m_TreeView.SetSelection(Selection.instanceIDs, revealSelectionAndFrameLastSelected);
        }
 public static void CreateScene()
 {
     StartNameEditingIfProjectWindowExists(0, ScriptableObject.CreateInstance <DoCreateScene>(), "New Scene.unity", EditorGUIUtility.FindTexture(typeof(SceneAsset)), null);
 }
        private void DrawParentView(Rect r, ref GUIHistoryListItem item, int changesetIndex, bool hasFocus)
        {
            ParentViewState assets   = item.assets;
            GUIContent      content  = new GUIContent();
            Texture2D       textured = EditorGUIUtility.FindTexture(EditorResourcesUtility.folderIconName);
            Event           current  = Event.current;

            hasFocus &= this.m_HistoryControlID == GUIUtility.keyboardControl;
            r.height  = this.m_RowHeight;
            r.y      += 3f;
            int index = -1;
            int num2  = (item.collapsedItemCount == 0) ? item.totalLineCount : 4;

            num2 += item.startShowingFrom;
            for (int i = 0; i < assets.folders.Length; i++)
            {
                GUIStyle         label;
                ParentViewFolder folder = assets.folders[i];
                content.text  = folder.name;
                content.image = textured;
                index++;
                if (index == num2)
                {
                    break;
                }
                if (index >= item.startShowingFrom)
                {
                    label = ms_Style.label;
                    if ((current.type == EventType.MouseDown) && r.Contains(current.mousePosition))
                    {
                        if (((this.ChangeLogSelectionRev == this.m_Changesets[changesetIndex].changeset) && (this.m_ChangeLogSelectionGUID == folder.guid)) && EditorGUI.actionKey)
                        {
                            this.ClearItemSelection();
                        }
                        else
                        {
                            this.ChangeLogSelectionRev         = this.m_Changesets[changesetIndex].changeset;
                            this.m_ChangeLogSelectionGUID      = folder.guid;
                            this.m_ChangeLogSelectionAssetName = folder.name;
                            this.m_FolderSelected      = true;
                            this.m_AssetSelectionIndex = index;
                        }
                        this.m_ChangesetSelectionIndex = changesetIndex;
                        GUIUtility.keyboardControl     = this.m_HistoryControlID;
                        ((ASMainWindow)this.m_ParentWindow).m_SearchToShow = ASMainWindow.ShowSearchField.HistoryList;
                        if (current.clickCount == 2)
                        {
                            this.ShowAssetsHistory();
                            GUIUtility.ExitGUI();
                        }
                        else if (current.button == 1)
                        {
                            GUIUtility.hotControl = 0;
                            r = new Rect(current.mousePosition.x, current.mousePosition.y, 1f, 1f);
                            EditorUtility.DisplayCustomMenu(r, this.m_DropDownMenuItems, -1, new EditorUtility.SelectMenuItemFunction(this.ContextMenuClick), null);
                        }
                        this.DoScroll();
                        current.Use();
                    }
                    bool on = (this.ChangeLogSelectionRev == this.m_Changesets[changesetIndex].changeset) && (this.m_ChangeLogSelectionGUID == folder.guid);
                    if (item.boldAssets[index] && !on)
                    {
                        GUI.Label(r, string.Empty, ms_Style.ping);
                    }
                    if (Event.current.type == EventType.Repaint)
                    {
                        label.Draw(r, content, false, false, on, hasFocus);
                        this.DrawBadge(r, folder.changeFlags, label, content, GUIClip.visibleRect.width - 150f);
                    }
                    r.y += this.m_RowHeight;
                }
                RectOffset padding = ms_Style.label.padding;
                padding.left += 0x10;
                RectOffset offset2 = ms_Style.boldLabel.padding;
                offset2.left += 0x10;
                try
                {
                    for (int j = 0; j < folder.files.Length; j++)
                    {
                        index++;
                        if (index == num2)
                        {
                            break;
                        }
                        if (index >= item.startShowingFrom)
                        {
                            label = ms_Style.label;
                            if ((current.type == EventType.MouseDown) && r.Contains(current.mousePosition))
                            {
                                if (((this.ChangeLogSelectionRev == this.m_Changesets[changesetIndex].changeset) && (this.m_ChangeLogSelectionGUID == folder.files[j].guid)) && EditorGUI.actionKey)
                                {
                                    this.ClearItemSelection();
                                }
                                else
                                {
                                    this.ChangeLogSelectionRev         = this.m_Changesets[changesetIndex].changeset;
                                    this.m_ChangeLogSelectionGUID      = folder.files[j].guid;
                                    this.m_ChangeLogSelectionAssetName = folder.files[j].name;
                                    this.m_FolderSelected      = false;
                                    this.m_AssetSelectionIndex = index;
                                }
                                this.m_ChangesetSelectionIndex = changesetIndex;
                                GUIUtility.keyboardControl     = this.m_HistoryControlID;
                                ((ASMainWindow)this.m_ParentWindow).m_SearchToShow = ASMainWindow.ShowSearchField.HistoryList;
                                if (current.clickCount == 2)
                                {
                                    if (this.IsComparableAssetSelected() && (this.m_SelectedGUID == this.m_ChangeLogSelectionGUID))
                                    {
                                        this.DoShowDiff(false, this.ChangeLogSelectionRev, -1);
                                    }
                                    else
                                    {
                                        this.ShowAssetsHistory();
                                        GUIUtility.ExitGUI();
                                    }
                                }
                                else if (current.button == 1)
                                {
                                    GUIUtility.hotControl = 0;
                                    r = new Rect(current.mousePosition.x, current.mousePosition.y, 1f, 1f);
                                    EditorUtility.DisplayCustomMenu(r, this.m_DropDownMenuItems, -1, new EditorUtility.SelectMenuItemFunction(this.ContextMenuClick), null);
                                }
                                this.DoScroll();
                                current.Use();
                            }
                            content.text  = folder.files[j].name;
                            content.image = InternalEditorUtility.GetIconForFile(folder.files[j].name);
                            bool flag2 = (this.ChangeLogSelectionRev == this.m_Changesets[changesetIndex].changeset) && (this.m_ChangeLogSelectionGUID == folder.files[j].guid);
                            if (item.boldAssets[index] && !flag2)
                            {
                                GUI.Label(r, string.Empty, ms_Style.ping);
                            }
                            if (Event.current.type == EventType.Repaint)
                            {
                                label.Draw(r, content, false, false, flag2, hasFocus);
                                this.DrawBadge(r, folder.files[j].changeFlags, label, content, GUIClip.visibleRect.width - 150f);
                            }
                            r.y += this.m_RowHeight;
                        }
                    }
                    if (index == num2)
                    {
                        break;
                    }
                }
                finally
                {
                    RectOffset offset3 = ms_Style.label.padding;
                    offset3.left -= 0x10;
                    RectOffset offset4 = ms_Style.boldLabel.padding;
                    offset4.left -= 0x10;
                }
            }
            if (((index == num2) || (num2 >= item.totalLineCount)) && (item.collapsedItemCount != 0))
            {
                r.x += 19f;
                if (GUI.Button(r, item.collapsedItemCount.ToString() + " more...", ms_Style.foldout))
                {
                    GUIUtility.keyboardControl = this.m_HistoryControlID;
                    this.UncollapseListItem(ref item);
                }
            }
        }
Beispiel #8
0
        public override void FetchData()
        {
            // Create root Item
            int depth = 0;

            m_RootItem = new TreeViewItem(m_RootInstanceID, depth, null, CreateDisplayName(m_RootInstanceID));
            if (!showRootItem)
            {
                SetExpanded(m_RootItem, true);
            }

            // Find start Item
            var property = new HierarchyProperty(k_HierarchyType, false);

            property.Reset();
            bool found = property.Find(m_RootInstanceID, null);

            if (!found)
            {
                Debug.LogError("Root Asset with id " + m_RootInstanceID + " not found!!");
            }

            int minDepth = property.depth + (showRootItem ? 0 : 1);

            int[]     expanded        = expandedIDs.ToArray();
            Texture2D emptyFolderIcon = EditorGUIUtility.FindTexture(EditorResources.emptyFolderIconName);

            // Fetch visible items
            m_Rows = new List <TreeViewItem>();
            while (property.NextWithDepthCheck(expanded, minDepth))
            {
                if (!foldersOnly || property.isFolder)
                {
                    depth = property.depth - minDepth;
                    TreeViewItem item;
                    if (property.isFolder)
                    {
                        item = new FolderTreeItem(property.instanceID, depth, null, property.name);
                    }
                    else
                    {
                        item = new NonFolderTreeItem(property.instanceID, depth, null, property.name);
                    }

                    if (property.isFolder && !property.hasChildren)
                    {
                        item.icon = emptyFolderIcon;
                    }
                    else
                    {
                        item.icon = property.icon;
                    }

                    if (property.hasChildren)
                    {
                        item.AddChild(null); // add a dummy child in children list to ensure we show the collapse arrow (because we do not fetch data for collapsed items)
                    }
                    m_Rows.Add(item);
                }
            }

            // Setup reference between child and parent items
            TreeViewUtility.SetChildParentReferences(m_Rows, m_RootItem);

            if (foldersFirst)
            {
                FoldersFirstRecursive(m_RootItem);
                m_Rows.Clear();
                GetVisibleItemsRecursive(m_RootItem, m_Rows);
            }

            // Must be called before InitSelection (it calls GetVisibleItems)
            m_NeedRefreshRows = false;

            // We want to reset selection on copy/duplication/delete
            bool frameLastSelected = false; // use false because we might just be expanding/collapsing a Item (which would prevent collapsing a Item with a selected child)

            m_TreeView.SetSelection(Selection.instanceIDs, frameLastSelected);
        }
Beispiel #9
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;
        }
Beispiel #10
0
        public void DoGUI(ASHistoryWindow parentWin, Rect theRect, bool focused)
        {
            if (ms_Styles == null)
            {
                ms_Styles = new Styles();
            }
            this.m_ScreenRect = theRect;
            Hashtable hashtable = new Hashtable();

            foreach (Object obj2 in Selection.objects)
            {
                hashtable.Add(obj2.GetInstanceID(), null);
            }
            this.m_FileViewControlID = GUIUtility.GetControlID(ms_FileViewHash, FocusType.Native);
            this.KeyboardGUI(parentWin);
            focused &= GUIUtility.keyboardControl == this.m_FileViewControlID;
            HierarchyProperty property = new HierarchyProperty(HierarchyType.Assets);
            int  num2     = property.CountRemaining(this.m_ExpandedArray);
            int  num3     = !this.DeletedItemsToggle ? 0 : this.m_DelPVstate.lv.totalRows;
            Rect viewRect = new Rect(0f, 0f, 1f, (((num2 + 2) + num3) * m_RowHeight) + 16f);

            this.m_ScrollPosition = GUI.BeginScrollView(this.m_ScreenRect, this.m_ScrollPosition, viewRect);
            theRect.width         = (viewRect.height <= this.m_ScreenRect.height) ? theRect.width : (theRect.width - 18f);
            int count = Mathf.RoundToInt((this.m_ScrollPosition.y - 6f) - m_RowHeight) / Mathf.RoundToInt(m_RowHeight);

            if (count > num2)
            {
                count = num2;
            }
            else if (count < 0)
            {
                count = 0;
                this.m_ScrollPosition.y = 0f;
            }
            float      y        = 0f;
            GUIContent content  = new GUIContent();
            Event      current  = Event.current;
            GUIStyle   s        = new GUIStyle(ms_Styles.label);
            Texture2D  textured = EditorGUIUtility.FindTexture(EditorResourcesUtility.folderIconName);

            y = (count * m_RowHeight) + 3f;
            float endOffset = this.m_ScreenRect.height + this.m_ScrollPosition.y;
            Rect  position  = new Rect(0f, y, theRect.width, m_RowHeight);

            if ((current.type == EventType.MouseDown) && position.Contains(current.mousePosition))
            {
                this.SelType = SelectionType.All;
                GUIUtility.keyboardControl = this.m_FileViewControlID;
                this.ScrollTo(0f);
                parentWin.DoLocalSelectionChange();
                current.Use();
            }
            content = new GUIContent("Entire Project")
            {
                image = textured
            };
            int baseIndent = (int)this.m_BaseIndent;

            s.padding.left = 3;
            if (Event.current.type == EventType.Repaint)
            {
                s.Draw(position, content, false, false, this.SelType == SelectionType.All, focused);
            }
            y += m_RowHeight + 3f;
            property.Reset();
            property.Skip(count, this.m_ExpandedArray);
            while (property.Next(this.m_ExpandedArray) && (y <= endOffset))
            {
                int instanceID = property.instanceID;
                position = new Rect(0f, y, theRect.width, m_RowHeight);
                if (Event.current.type == EventType.Repaint)
                {
                    content.text   = property.name;
                    content.image  = property.icon;
                    baseIndent     = (int)(this.m_BaseIndent + (this.m_Indent * property.depth));
                    s.padding.left = baseIndent;
                    bool on = hashtable.Contains(instanceID);
                    s.Draw(position, content, false, false, on, focused);
                }
                if (property.hasChildren)
                {
                    bool flag2 = property.IsExpanded(this.m_ExpandedArray);
                    GUI.changed = false;
                    Rect rect3 = new Rect((this.m_BaseIndent + (this.m_Indent * property.depth)) - this.m_FoldoutSize, y, this.m_FoldoutSize, m_RowHeight);
                    flag2 = GUI.Toggle(rect3, flag2, GUIContent.none, ms_Styles.foldout);
                    if (GUI.changed)
                    {
                        if (Event.current.alt)
                        {
                            this.SetExpandedRecurse(instanceID, flag2);
                        }
                        else
                        {
                            this.SetExpanded(instanceID, flag2);
                        }
                    }
                }
                if (((current.type == EventType.MouseDown) && (Event.current.button == 0)) && position.Contains(Event.current.mousePosition))
                {
                    GUIUtility.keyboardControl = this.m_FileViewControlID;
                    if (Event.current.clickCount == 2)
                    {
                        AssetDatabase.OpenAsset(instanceID);
                        GUIUtility.ExitGUI();
                    }
                    else if (position.Contains(current.mousePosition))
                    {
                        this.SelectionClick(property);
                    }
                    current.Use();
                }
                y += m_RowHeight;
            }
            y += 3f;
            this.DoDeletedItemsGUI(parentWin, theRect, s, y, endOffset, focused);
            GUI.EndScrollView();
            switch (current.type)
            {
            case EventType.MouseDown:
                if ((current.button == 0) && this.m_ScreenRect.Contains(current.mousePosition))
                {
                    GUIUtility.hotControl = this.m_FileViewControlID;
                    current.Use();
                }
                break;

            case EventType.MouseUp:
                if (GUIUtility.hotControl == this.m_FileViewControlID)
                {
                    if (this.m_ScreenRect.Contains(current.mousePosition))
                    {
                        Selection.activeObject = null;
                    }
                    GUIUtility.hotControl = 0;
                    current.Use();
                }
                break;
            }
            this.HandleFraming();
        }
 static Constants()
 {
     PackageImportTreeView.PackageImportTreeViewGUI.Constants.folderIcon               = EditorGUIUtility.FindTexture(EditorResourcesUtility.folderIconName);
     PackageImportTreeView.PackageImportTreeViewGUI.Constants.badgeNew                 = EditorGUIUtility.IconContent("AS Badge New", "|This is a new Asset");
     PackageImportTreeView.PackageImportTreeViewGUI.Constants.badgeDelete              = EditorGUIUtility.IconContent("AS Badge Delete", "|These files will be deleted!");
     PackageImportTreeView.PackageImportTreeViewGUI.Constants.badgeWarn                = EditorGUIUtility.IconContent("console.warnicon", "|Warning: File exists in project, but with different GUID. Will override existing asset which may be undesired.");
     PackageImportTreeView.PackageImportTreeViewGUI.Constants.badgeChange              = EditorGUIUtility.IconContent("playLoopOff", "|This file is new or has changed.");
     PackageImportTreeView.PackageImportTreeViewGUI.Constants.paddinglessStyle         = new GUIStyle();
     PackageImportTreeView.PackageImportTreeViewGUI.Constants.paddinglessStyle.padding = new RectOffset(0, 0, 0, 0);
 }
Beispiel #12
0
        public void DoDeletedItemsGUI(ASHistoryWindow parentWin, Rect theRect, GUIStyle s, float offset, float endOffset, bool focused)
        {
            Event     current  = Event.current;
            Texture2D textured = EditorGUIUtility.FindTexture(EditorResourcesUtility.folderIconName);

            offset += 3f;
            Rect position = new Rect(this.m_Indent, offset, theRect.width - this.m_Indent, m_RowHeight);

            if ((current.type == EventType.MouseDown) && position.Contains(current.mousePosition))
            {
                GUIUtility.keyboardControl = this.m_FileViewControlID;
                this.SelType = SelectionType.DeletedItemsRoot;
                this.ScrollToDeletedItem(-1);
                parentWin.DoLocalSelectionChange();
            }
            position.width -= position.x;
            position.x      = 0f;
            GUIContent content = new GUIContent("Deleted Assets")
            {
                image = textured
            };
            int baseIndent = (int)this.m_BaseIndent;

            s.padding.left = baseIndent;
            if (current.type == EventType.Repaint)
            {
                s.Draw(position, content, false, false, this.SelType == SelectionType.DeletedItemsRoot, focused);
            }
            Rect rect2 = new Rect(this.m_BaseIndent - this.m_FoldoutSize, offset, this.m_FoldoutSize, m_RowHeight);

            if (!this.m_DeletedItemsInitialized || (this.m_DelPVstate.lv.totalRows != 0))
            {
                this.DeletedItemsToggle = GUI.Toggle(rect2, this.DeletedItemsToggle, GUIContent.none, ms_Styles.foldout);
            }
            offset += m_RowHeight;
            if (this.DeletedItemsToggle)
            {
                int row   = this.m_DelPVstate.lv.row;
                int index = 0;
                int num4  = -1;
                int file  = -1;
                int num6  = 0;
                while ((offset <= endOffset) && (num6 < this.m_DelPVstate.lv.totalRows))
                {
                    if ((offset + m_RowHeight) >= 0f)
                    {
                        if (num4 == -1)
                        {
                            this.m_DelPVstate.IndexToFolderAndFile(num6, ref num4, ref file);
                        }
                        position = new Rect(0f, offset, (float)Screen.width, m_RowHeight);
                        ParentViewFolder folder = this.m_DelPVstate.folders[num4];
                        if ((current.type == EventType.MouseDown) && position.Contains(current.mousePosition))
                        {
                            if (!(((current.button == 1) && (this.SelType == SelectionType.DeletedItems)) && this.m_DelPVstate.selectedItems[index]))
                            {
                                GUIUtility.keyboardControl = this.m_FileViewControlID;
                                this.SelType             = SelectionType.DeletedItems;
                                this.m_DelPVstate.lv.row = index;
                                ListViewShared.MultiSelection(null, row, this.m_DelPVstate.lv.row, ref this.m_DelPVstate.initialSelectedItem, ref this.m_DelPVstate.selectedItems);
                                this.ScrollToDeletedItem(index);
                                parentWin.DoLocalSelectionChange();
                            }
                            if ((current.button == 1) && (this.SelType == SelectionType.DeletedItems))
                            {
                                GUIUtility.hotControl = 0;
                                Rect rect3 = new Rect(current.mousePosition.x, current.mousePosition.y, 1f, 1f);
                                EditorUtility.DisplayCustomMenu(rect3, this.dropDownMenuItems, -1, new EditorUtility.SelectMenuItemFunction(this.ContextMenuClick), null);
                            }
                            Event.current.Use();
                        }
                        if (file != -1)
                        {
                            content.text  = folder.files[file].name;
                            content.image = InternalEditorUtility.GetIconForFile(folder.files[file].name);
                            baseIndent    = (int)(this.m_BaseIndent + (this.m_Indent * 2f));
                        }
                        else
                        {
                            content.text  = folder.name;
                            content.image = textured;
                            baseIndent    = (int)(this.m_BaseIndent + this.m_Indent);
                        }
                        s.padding.left = baseIndent;
                        if (Event.current.type == EventType.Repaint)
                        {
                            s.Draw(position, content, false, false, this.m_DelPVstate.selectedItems[index], focused);
                        }
                        this.m_DelPVstate.NextFileFolder(ref num4, ref file);
                        index++;
                    }
                    num6++;
                    offset += m_RowHeight;
                }
            }
        }
 static GameObjectStyles()
 {
     GameObjectTreeViewGUI.GameObjectStyles.disabledLabel                       = new GUIStyle("PR DisabledLabel");
     GameObjectTreeViewGUI.GameObjectStyles.prefabLabel                         = new GUIStyle("PR PrefabLabel");
     GameObjectTreeViewGUI.GameObjectStyles.disabledPrefabLabel                 = new GUIStyle("PR DisabledPrefabLabel");
     GameObjectTreeViewGUI.GameObjectStyles.brokenPrefabLabel                   = new GUIStyle("PR BrokenPrefabLabel");
     GameObjectTreeViewGUI.GameObjectStyles.disabledBrokenPrefabLabel           = new GUIStyle("PR DisabledBrokenPrefabLabel");
     GameObjectTreeViewGUI.GameObjectStyles.loadSceneGUIContent                 = new GUIContent(EditorGUIUtility.FindTexture("SceneLoadIn"), "Load scene");
     GameObjectTreeViewGUI.GameObjectStyles.unloadSceneGUIContent               = new GUIContent(EditorGUIUtility.FindTexture("SceneLoadOut"), "Unload scene");
     GameObjectTreeViewGUI.GameObjectStyles.saveSceneGUIContent                 = new GUIContent(EditorGUIUtility.FindTexture("SceneSave"), "Save scene");
     GameObjectTreeViewGUI.GameObjectStyles.optionsButtonStyle                  = "PaneOptions";
     GameObjectTreeViewGUI.GameObjectStyles.sceneHeaderBg                       = "ProjectBrowserTopBarBg";
     GameObjectTreeViewGUI.GameObjectStyles.kSceneHeaderIconsInterval           = 2;
     GameObjectTreeViewGUI.GameObjectStyles.disabledLabel.alignment             = TextAnchor.MiddleLeft;
     GameObjectTreeViewGUI.GameObjectStyles.prefabLabel.alignment               = TextAnchor.MiddleLeft;
     GameObjectTreeViewGUI.GameObjectStyles.disabledPrefabLabel.alignment       = TextAnchor.MiddleLeft;
     GameObjectTreeViewGUI.GameObjectStyles.brokenPrefabLabel.alignment         = TextAnchor.MiddleLeft;
     GameObjectTreeViewGUI.GameObjectStyles.disabledBrokenPrefabLabel.alignment = TextAnchor.MiddleLeft;
     GameObjectTreeViewGUI.GameObjectStyles.ClearSelectionTexture(GameObjectTreeViewGUI.GameObjectStyles.disabledLabel);
     GameObjectTreeViewGUI.GameObjectStyles.ClearSelectionTexture(GameObjectTreeViewGUI.GameObjectStyles.prefabLabel);
     GameObjectTreeViewGUI.GameObjectStyles.ClearSelectionTexture(GameObjectTreeViewGUI.GameObjectStyles.disabledPrefabLabel);
     GameObjectTreeViewGUI.GameObjectStyles.ClearSelectionTexture(GameObjectTreeViewGUI.GameObjectStyles.brokenPrefabLabel);
     GameObjectTreeViewGUI.GameObjectStyles.ClearSelectionTexture(GameObjectTreeViewGUI.GameObjectStyles.disabledBrokenPrefabLabel);
 }
Beispiel #14
0
        public void DoGUI(ASHistoryWindow parentWin, Rect theRect, bool focused)
        {
            if (ASHistoryFileView.ms_Styles == null)
            {
                ASHistoryFileView.ms_Styles = new ASHistoryFileView.Styles();
            }
            this.m_ScreenRect = theRect;
            Hashtable hashtable = new Hashtable();

            UnityEngine.Object[] objects = Selection.objects;
            for (int i = 0; i < objects.Length; i++)
            {
                UnityEngine.Object @object = objects[i];
                hashtable.Add(@object.GetInstanceID(), null);
            }
            this.m_FileViewControlID = GUIUtility.GetControlID(ASHistoryFileView.ms_FileViewHash, FocusType.Passive);
            this.KeyboardGUI(parentWin);
            focused &= (GUIUtility.keyboardControl == this.m_FileViewControlID);
            HierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.Assets);
            int  num      = hierarchyProperty.CountRemaining(this.m_ExpandedArray);
            int  num2     = (!this.DeletedItemsToggle) ? 0 : this.m_DelPVstate.lv.totalRows;
            Rect viewRect = new Rect(0f, 0f, 1f, (float)(num + 2 + num2) * ASHistoryFileView.m_RowHeight + 16f);

            this.m_ScrollPosition = GUI.BeginScrollView(this.m_ScreenRect, this.m_ScrollPosition, viewRect);
            theRect.width         = ((viewRect.height <= this.m_ScreenRect.height) ? theRect.width : (theRect.width - 18f));
            int num3 = Mathf.RoundToInt(this.m_ScrollPosition.y - 6f - ASHistoryFileView.m_RowHeight) / Mathf.RoundToInt(ASHistoryFileView.m_RowHeight);

            if (num3 > num)
            {
                num3 = num;
            }
            else if (num3 < 0)
            {
                num3 = 0;
                this.m_ScrollPosition.y = 0f;
            }
            GUIContent gUIContent = new GUIContent();
            Event      current    = Event.current;
            GUIStyle   gUIStyle   = new GUIStyle(ASHistoryFileView.ms_Styles.label);
            Texture2D  image      = EditorGUIUtility.FindTexture(EditorResourcesUtility.folderIconName);
            float      num4       = (float)num3 * ASHistoryFileView.m_RowHeight + 3f;
            float      num5       = this.m_ScreenRect.height + this.m_ScrollPosition.y;
            Rect       position   = new Rect(0f, num4, theRect.width, ASHistoryFileView.m_RowHeight);

            if (current.type == EventType.MouseDown && position.Contains(current.mousePosition))
            {
                this.SelType = ASHistoryFileView.SelectionType.All;
                GUIUtility.keyboardControl = this.m_FileViewControlID;
                this.ScrollTo(0f);
                parentWin.DoLocalSelectionChange();
                current.Use();
            }
            gUIContent       = new GUIContent("Entire Project");
            gUIContent.image = image;
            int left = (int)this.m_BaseIndent;

            gUIStyle.padding.left = 3;
            if (Event.current.type == EventType.Repaint)
            {
                gUIStyle.Draw(position, gUIContent, false, false, this.SelType == ASHistoryFileView.SelectionType.All, focused);
            }
            num4 += ASHistoryFileView.m_RowHeight + 3f;
            hierarchyProperty.Reset();
            hierarchyProperty.Skip(num3, this.m_ExpandedArray);
            while (hierarchyProperty.Next(this.m_ExpandedArray) && num4 <= num5)
            {
                int instanceID = hierarchyProperty.instanceID;
                position = new Rect(0f, num4, theRect.width, ASHistoryFileView.m_RowHeight);
                if (Event.current.type == EventType.Repaint)
                {
                    gUIContent.text       = hierarchyProperty.name;
                    gUIContent.image      = hierarchyProperty.icon;
                    left                  = (int)(this.m_BaseIndent + this.m_Indent * (float)hierarchyProperty.depth);
                    gUIStyle.padding.left = left;
                    bool on = hashtable.Contains(instanceID);
                    gUIStyle.Draw(position, gUIContent, false, false, on, focused);
                }
                if (hierarchyProperty.hasChildren)
                {
                    bool flag = hierarchyProperty.IsExpanded(this.m_ExpandedArray);
                    GUI.changed = false;
                    Rect position2 = new Rect(this.m_BaseIndent + this.m_Indent * (float)hierarchyProperty.depth - this.m_FoldoutSize, num4, this.m_FoldoutSize, ASHistoryFileView.m_RowHeight);
                    flag = GUI.Toggle(position2, flag, GUIContent.none, ASHistoryFileView.ms_Styles.foldout);
                    if (GUI.changed)
                    {
                        if (Event.current.alt)
                        {
                            this.SetExpandedRecurse(instanceID, flag);
                        }
                        else
                        {
                            this.SetExpanded(instanceID, flag);
                        }
                    }
                }
                if (current.type == EventType.MouseDown && Event.current.button == 0 && position.Contains(Event.current.mousePosition))
                {
                    GUIUtility.keyboardControl = this.m_FileViewControlID;
                    if (Event.current.clickCount == 2)
                    {
                        AssetDatabase.OpenAsset(instanceID);
                        GUIUtility.ExitGUI();
                    }
                    else if (position.Contains(current.mousePosition))
                    {
                        this.SelectionClick(hierarchyProperty);
                    }
                    current.Use();
                }
                num4 += ASHistoryFileView.m_RowHeight;
            }
            num4 += 3f;
            this.DoDeletedItemsGUI(parentWin, theRect, gUIStyle, num4, num5, focused);
            GUI.EndScrollView();
            EventType type = current.type;

            if (type != EventType.MouseDown)
            {
                if (type == EventType.MouseUp)
                {
                    if (GUIUtility.hotControl == this.m_FileViewControlID)
                    {
                        if (this.m_ScreenRect.Contains(current.mousePosition))
                        {
                            Selection.activeObject = null;
                        }
                        GUIUtility.hotControl = 0;
                        current.Use();
                    }
                }
            }
            else if (current.button == 0 && this.m_ScreenRect.Contains(current.mousePosition))
            {
                GUIUtility.hotControl = this.m_FileViewControlID;
                current.Use();
            }
            this.HandleFraming();
        }
 public GroupTreeViewGUI(TreeViewController treeView) : base(treeView)
 {
     this.k_AudioGroupIcon    = EditorGUIUtility.FindTexture("AudioMixerGroup Icon");
     this.k_AudioListenerIcon = EditorGUIUtility.FindTexture("AudioListener Icon");
     this.m_RowRects          = new List <Rect>();
 }
Beispiel #16
0
 public ProjectBrowserColumnOneTreeViewGUI(TreeView treeView) : base(treeView)
 {
     this.k_FavoritesIcon      = EditorGUIUtility.FindTexture("Favorite Icon");
     this.k_FavoriteFolderIcon = EditorGUIUtility.FindTexture("FolderFavorite Icon");
     this.k_FavoriteFilterIcon = EditorGUIUtility.FindTexture("Search Icon");
 }
 public SketchUpTreeViewGUI(TreeView treeView) : base(treeView)
 {
     this.k_Root       = EditorGUIUtility.FindTexture("DefaultAsset Icon");
     this.k_Icon       = EditorGUIUtility.FindTexture("Mesh Icon");
     base.k_BaseIndent = 20f;
 }
Beispiel #18
0
        private void DoDownloadConflictsGUI()
        {
            bool enabled   = GUI.enabled;
            bool shift     = Event.current.shift;
            bool actionKey = EditorGUI.actionKey;

            GUILayout.BeginVertical(new GUILayoutOption[0]);
            GUILayout.Label("The following assets have been changed both on the server and in the local project.\nPlease select a conflict resolution for each before continuing the update.", new GUILayoutOption[0]);
            GUILayout.Space(10f);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            GUI.enabled = (this.lv1HasSelection && enabled);
            if (GUILayout.Button(ASUpdateConflictResolveWindow.conflictButtonTexts[0], this.constants.ButtonLeft, new GUILayoutOption[0]))
            {
                this.ResolveSelectedDownloadConflicts(DownloadResolution.SkipAsset);
            }
            if (GUILayout.Button(ASUpdateConflictResolveWindow.conflictButtonTexts[1], this.constants.ButtonMiddle, new GUILayoutOption[0]))
            {
                this.ResolveSelectedDownloadConflicts(DownloadResolution.TrashMyChanges);
            }
            if (GUILayout.Button(ASUpdateConflictResolveWindow.conflictButtonTexts[2], this.constants.ButtonMiddle, new GUILayoutOption[0]))
            {
                this.ResolveSelectedDownloadConflicts(DownloadResolution.TrashServerChanges);
            }
            if (!this.enableMergeButton)
            {
                GUI.enabled = false;
            }
            if (GUILayout.Button(ASUpdateConflictResolveWindow.conflictButtonTexts[3], this.constants.ButtonRight, new GUILayoutOption[0]))
            {
                this.ResolveSelectedDownloadConflicts(DownloadResolution.Merge);
            }
            GUI.enabled = enabled;
            GUILayout.EndHorizontal();
            GUILayout.Space(5f);
            SplitterGUILayout.BeginHorizontalSplit(this.lvHeaderSplit1, new GUILayoutOption[0]);
            GUILayout.Box("Action", this.constants.lvHeader, new GUILayoutOption[0]);
            GUILayout.Box("Asset", this.constants.lvHeader, new GUILayoutOption[0]);
            SplitterGUILayout.EndHorizontalSplit();
            int  row  = this.lv1.row;
            bool flag = false;

            foreach (ListViewElement listViewElement in ListViewGUILayout.ListView(this.lv1, this.constants.background, new GUILayoutOption[0]))
            {
                if (GUIUtility.keyboardControl == this.lv1.ID && Event.current.type == EventType.KeyDown && actionKey)
                {
                    Event.current.Use();
                }
                if (this.selectedLV1Items[listViewElement.row] && Event.current.type == EventType.Repaint)
                {
                    this.constants.selected.Draw(listViewElement.position, false, false, false, false);
                }
                if (ListViewGUILayout.HasMouseUp(listViewElement.position))
                {
                    if (!shift && !actionKey)
                    {
                        flag |= ListViewGUILayout.MultiSelection(row, this.lv1.row, ref this.initialSelectedLV1Item, ref this.selectedLV1Items);
                    }
                }
                else
                {
                    if (ListViewGUILayout.HasMouseDown(listViewElement.position))
                    {
                        if (Event.current.clickCount == 2 && !AssetServer.AssetIsDir(this.downloadConflicts[listViewElement.row]))
                        {
                            this.DoShowDiff(false);
                            GUIUtility.ExitGUI();
                        }
                        else
                        {
                            if (!this.selectedLV1Items[listViewElement.row] || shift || actionKey)
                            {
                                flag |= ListViewGUILayout.MultiSelection(row, listViewElement.row, ref this.initialSelectedLV1Item, ref this.selectedLV1Items);
                            }
                            this.lv1.row = listViewElement.row;
                        }
                    }
                    else
                    {
                        if (ListViewGUILayout.HasMouseDown(listViewElement.position, 1))
                        {
                            if (!this.selectedLV1Items[listViewElement.row])
                            {
                                flag = true;
                                for (int i = 0; i < this.selectedLV1Items.Length; i++)
                                {
                                    this.selectedLV1Items[i] = false;
                                }
                                this.lv1.selectionChanged = true;
                                this.selectedLV1Items[listViewElement.row] = true;
                                this.lv1.row = listViewElement.row;
                            }
                            GUIUtility.hotControl = 0;
                            Rect position = new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 1f, 1f);
                            EditorUtility.DisplayCustomMenu(position, this.dropDownMenuItems, null, new EditorUtility.SelectMenuItemFunction(this.ContextMenuClick), null);
                            Event.current.Use();
                        }
                    }
                }
                GUILayout.Label(this.downloadResolutionString[(int)this.downloadResolutions[listViewElement.row]], new GUILayoutOption[]
                {
                    GUILayout.Width((float)this.lvHeaderSplit1.realSizes[0]),
                    GUILayout.Height(18f)
                });
                if (this.deletionConflict[listViewElement.row] && Event.current.type == EventType.Repaint)
                {
                    GUIContent badgeDelete = ASMainWindow.constants.badgeDelete;
                    Rect       position2   = new Rect(listViewElement.position.x + (float)this.lvHeaderSplit1.realSizes[0] - (float)badgeDelete.image.width - 5f, listViewElement.position.y + listViewElement.position.height / 2f - (float)(badgeDelete.image.height / 2), (float)badgeDelete.image.width, (float)badgeDelete.image.height);
                    EditorGUIUtility.SetIconSize(Vector2.zero);
                    GUIStyle.none.Draw(position2, badgeDelete, false, false, false, false);
                    EditorGUIUtility.SetIconSize(this.iconSize);
                }
                GUILayout.Label(new GUIContent(this.dConflictPaths[listViewElement.row], (!AssetServer.AssetIsDir(this.downloadConflicts[listViewElement.row])) ? InternalEditorUtility.GetIconForFile(this.dConflictPaths[listViewElement.row]) : EditorGUIUtility.FindTexture(EditorResourcesUtility.folderIconName)), new GUILayoutOption[]
                {
                    GUILayout.Width((float)this.lvHeaderSplit1.realSizes[1]),
                    GUILayout.Height(18f)
                });
            }
            GUILayout.EndVertical();
            if (GUIUtility.keyboardControl == this.lv1.ID)
            {
                if (Event.current.type == EventType.ValidateCommand && Event.current.commandName == "SelectAll")
                {
                    Event.current.Use();
                }
                else
                {
                    if (Event.current.type == EventType.ExecuteCommand && Event.current.commandName == "SelectAll")
                    {
                        for (int j = 0; j < this.selectedLV1Items.Length; j++)
                        {
                            this.selectedLV1Items[j] = true;
                        }
                        flag = true;
                        Event.current.Use();
                    }
                }
                if (this.lv1.selectionChanged && !actionKey)
                {
                    flag |= ListViewGUILayout.MultiSelection(row, this.lv1.row, ref this.initialSelectedLV1Item, ref this.selectedLV1Items);
                }
                else
                {
                    if (GUIUtility.keyboardControl == this.lv1.ID && Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return && !AssetServer.AssetIsDir(this.downloadConflicts[this.lv1.row]))
                    {
                        this.DoShowDiff(false);
                        GUIUtility.ExitGUI();
                    }
                }
            }
            if (this.lv1.selectionChanged || flag)
            {
                this.mySelection = true;
                AssetServer.SetSelectionFromGUIDs(this.GetSelectedGUIDs());
                this.lv1HasSelection   = this.HasTrue(ref this.selectedLV1Items);
                this.enableMergeButton = this.AtLeastOneSelectedAssetCanBeMerged();
            }
        }
Beispiel #19
0
 public Styles()
 {
     scrollShadowTexture = EditorGUIUtility.FindTexture("ScrollShadow");
 }
Beispiel #20
0
        private void DoNamingConflictsGUI()
        {
            bool enabled   = GUI.enabled;
            bool shift     = Event.current.shift;
            bool actionKey = EditorGUI.actionKey;

            GUILayout.BeginVertical(new GUILayoutOption[0]);
            GUILayout.Space(10f);
            GUILayout.Label("The following assets have the same name as an existing asset on the server.\nPlease select which one to rename before continuing the update.", new GUILayoutOption[0]);
            GUILayout.Space(10f);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            GUI.enabled = (this.lv2HasSelection && enabled);
            if (GUILayout.Button(ASUpdateConflictResolveWindow.nameConflictButtonTexts[0], this.constants.ButtonLeft, new GUILayoutOption[0]))
            {
                this.ResolveSelectedNamingConflicts(NameConflictResolution.RenameLocal);
            }
            if (GUILayout.Button(ASUpdateConflictResolveWindow.nameConflictButtonTexts[1], this.constants.ButtonRight, new GUILayoutOption[0]))
            {
                this.ResolveSelectedNamingConflicts(NameConflictResolution.RenameRemote);
            }
            GUI.enabled = enabled;
            GUILayout.EndHorizontal();
            GUILayout.Space(5f);
            SplitterGUILayout.BeginHorizontalSplit(this.lvHeaderSplit2, new GUILayoutOption[0]);
            GUILayout.Box("Action", this.constants.lvHeader, new GUILayoutOption[0]);
            GUILayout.Box("Asset", this.constants.lvHeader, new GUILayoutOption[0]);
            SplitterGUILayout.EndHorizontalSplit();
            int  row  = this.lv2.row;
            bool flag = false;

            foreach (ListViewElement listViewElement in ListViewGUILayout.ListView(this.lv2, this.constants.background, new GUILayoutOption[0]))
            {
                if (GUIUtility.keyboardControl == this.lv2.ID && Event.current.type == EventType.KeyDown && actionKey)
                {
                    Event.current.Use();
                }
                if (this.selectedLV2Items[listViewElement.row] && Event.current.type == EventType.Repaint)
                {
                    this.constants.selected.Draw(listViewElement.position, false, false, false, false);
                }
                if (ListViewGUILayout.HasMouseUp(listViewElement.position))
                {
                    if (!shift && !actionKey)
                    {
                        flag |= ListViewGUILayout.MultiSelection(row, this.lv2.row, ref this.initialSelectedLV2Item, ref this.selectedLV2Items);
                    }
                }
                else
                {
                    if (ListViewGUILayout.HasMouseDown(listViewElement.position))
                    {
                        if (!this.selectedLV2Items[listViewElement.row] || shift || actionKey)
                        {
                            flag |= ListViewGUILayout.MultiSelection(row, listViewElement.row, ref this.initialSelectedLV2Item, ref this.selectedLV2Items);
                        }
                        this.lv2.row = listViewElement.row;
                    }
                }
                GUILayout.Label(this.namingResolutionString[(int)this.namingResolutions[listViewElement.row]], new GUILayoutOption[]
                {
                    GUILayout.Width((float)this.lvHeaderSplit2.realSizes[0]),
                    GUILayout.Height(18f)
                });
                GUILayout.Label(new GUIContent(this.dNamingPaths[listViewElement.row], (!AssetServer.AssetIsDir(this.nameConflicts[listViewElement.row])) ? InternalEditorUtility.GetIconForFile(this.dNamingPaths[listViewElement.row]) : EditorGUIUtility.FindTexture(EditorResourcesUtility.folderIconName)), new GUILayoutOption[]
                {
                    GUILayout.Width((float)this.lvHeaderSplit2.realSizes[1]),
                    GUILayout.Height(18f)
                });
            }
            GUILayout.EndVertical();
            if (GUIUtility.keyboardControl == this.lv2.ID)
            {
                if (Event.current.type == EventType.ValidateCommand && Event.current.commandName == "SelectAll")
                {
                    Event.current.Use();
                }
                else
                {
                    if (Event.current.type == EventType.ExecuteCommand && Event.current.commandName == "SelectAll")
                    {
                        for (int i = 0; i < this.selectedLV2Items.Length; i++)
                        {
                            this.selectedLV2Items[i] = true;
                        }
                        flag = true;
                        Event.current.Use();
                    }
                }
                if (this.lv2.selectionChanged && !actionKey)
                {
                    flag |= ListViewGUILayout.MultiSelection(row, this.lv2.row, ref this.initialSelectedLV2Item, ref this.selectedLV2Items);
                }
            }
            if (this.lv2.selectionChanged || flag)
            {
                this.mySelection = true;
                AssetServer.SetSelectionFromGUIDs(this.GetSelectedNamingGUIDs());
                this.lv2HasSelection = this.HasTrue(ref this.selectedLV2Items);
            }
        }
Beispiel #21
0
        public override void FetchData()
        {
            // Create root Item
            int depth     = 0;
            var multiRoot = (m_Roots.Count > 1);

            if (multiRoot)
            {
                m_RootItem = new TreeViewItem(-1, depth, null, "Invisible Root Item");
                SetExpanded(m_RootItem, true);
            }
            else
            {
                var rootInstanceID = m_Roots[0].instanceID;
                var displayName    = m_Roots[0].displayName ?? CreateDisplayName(rootInstanceID);
                m_RootItem = new TreeViewItem(rootInstanceID, depth, null, displayName);
                SetExpanded(m_RootItem, true);
            }

            m_Rows = new List <TreeViewItem>(m_Roots.Count * 256);
            Texture2D folderIcon        = EditorGUIUtility.FindTexture(EditorResources.folderIconName);
            var       assetsInstanceIDs = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID("Assets");
            var       projectPath       = Path.GetFileName(Directory.GetCurrentDirectory());

            // Fetch root Items
            m_RootsTreeViewItem = new Dictionary <string, TreeViewItem>(m_Roots.Count);
            foreach (var root in m_Roots)
            {
                var rootInstanceID = root.instanceID;
                var displayName    = root.displayName ?? CreateDisplayName(rootInstanceID);
                var rootPath       = root.path ?? AssetDatabase.GetAssetPath(rootInstanceID);
                var rootGuid       = AssetDatabase.AssetPathToGUID(rootPath);

                var property = new HierarchyProperty(rootPath);
                if (!root.skipValidation && !property.Find(rootInstanceID, null))
                {
                    if (rootInstanceID == 0)
                    {
                        Debug.LogError("Root Asset with path " + rootPath + " not valid!!");
                    }
                    continue;
                }

                var          minDepth = property.depth;
                var          subDepth = multiRoot ? 0 : -1;
                TreeViewItem rootItem;
                if (multiRoot)
                {
                    var parentItem = m_RootItem;
                    var rootDepth  = minDepth;
                    rootDepth++;

                    // Find parent treeView item
                    var parentPath = Directory.GetParent(rootPath).Name;
                    if (parentPath != projectPath)
                    {
                        if (!m_RootsTreeViewItem.TryGetValue(parentPath, out parentItem))
                        {
                            Debug.LogError("Cannot find parent for " + rootInstanceID);
                            continue;
                        }

                        rootDepth++;
                        subDepth++;
                    }

                    // Create root item TreeView item
                    if (subDepth > 0)
                    {
                        rootItem = new FolderTreeItem(rootGuid, !property.hasChildren, rootInstanceID, rootDepth, parentItem, displayName);
                    }
                    else
                    {
                        rootItem = new RootTreeItem(rootInstanceID, rootDepth, parentItem, displayName);
                    }
                    rootItem.icon = folderIcon;
                    parentItem.AddChild(rootItem);
                }
                else
                {
                    rootItem = m_RootItem;
                }

                m_RootsTreeViewItem[rootPath] = rootItem;

                if (!skipHiddenPackages)
                {
                    property.SetSearchFilter(new SearchFilter {
                        skipHidden = false
                    });
                }

                var  expandIDs      = GetExpandedIDs();
                var  rows           = new List <TreeViewItem>();
                bool shouldExpandIt = m_ExpandAtFirstTime && (rootItem.id == assetsInstanceIDs);
                if (IsExpanded(rootItem.id) && (rootItem == m_RootItem || IsExpanded(rootItem.parent.id)) || shouldExpandIt)
                {
                    m_ExpandAtFirstTime = false;

                    while (property.NextWithDepthCheck(expandIDs, minDepth))
                    {
                        if (!foldersOnly || property.isFolder)
                        {
                            depth = property.depth - minDepth;
                            TreeViewItem item;
                            if (property.isFolder)
                            {
                                item = new FolderTreeItem(property.guid, !property.hasChildren, property.instanceID, depth + subDepth, null, property.name);
                            }
                            else
                            {
                                item = new NonFolderTreeItem(property.guid, property.GetInstanceIDIfImported(), depth + subDepth, null, property.name);
                            }

                            item.icon = property.icon;

                            if (property.hasChildren)
                            {
                                item.AddChild(null); // add a dummy child in children list to ensure we show the collapse arrow (because we do not fetch data for collapsed items)
                            }
                            rows.Add(item);
                        }
                    }

                    // Setup reference between child and parent items
                    TreeViewUtility.SetChildParentReferences(rows, rootItem);
                }
                else
                {
                    rootItem.AddChild(null);
                }

                if (shouldExpandIt && !IsExpanded(rootItem))
                {
                    SetExpanded(rootItem, true);
                }

                if (multiRoot && IsExpanded(rootItem.parent.id))
                {
                    m_Rows.Add(rootItem);
                }

                ((List <TreeViewItem>)m_Rows).AddRange(rows);
            }

            if (foldersFirst)
            {
                FoldersFirstRecursive(m_RootItem);
                m_Rows.Clear();
                GetVisibleItemsRecursive(m_RootItem, m_Rows);
            }

            // Must be called before InitSelection (it calls GetVisibleItems)
            m_NeedRefreshRows = false;

            // We want to reset selection on copy/duplication/delete
            bool frameLastSelected = false; // use false because we might just be expanding/collapsing a Item (which would prevent collapsing a Item with a selected child)

            m_TreeView.SetSelection(Selection.instanceIDs, frameLastSelected);
        }
 public static void CreateScene()
 {
     ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, (EndNameEditAction)ScriptableObject.CreateInstance <DoCreateScene>(), "New Scene.unity", EditorGUIUtility.FindTexture("SceneAsset Icon"), (string)null);
 }