예제 #1
0
        public override void FetchData()
        {
            bool firstInitialize = !isInitialized;

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

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

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

            visibleRoots.Add(savedFiltersRootItem);

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

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

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

            m_RootItem.children = visibleRoots;

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

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

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

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

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

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

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

            m_NeedRefreshRows = false;
        }
예제 #2
0
            public PackageImportTreeViewItem(ImportPackageItem itemIn, int id, int depth, TreeViewItem parent, string displayName)
                : base(id, depth, parent, displayName)
            {
                item = itemIn;

                if (item == null)
                {
                    m_EnableState = EnabledState.All;
                }
                else
                {
                    m_EnableState = (EnabledState)item.enabledStatus;
                }
            }
예제 #3
0
 public override bool IsRenamingItemAllowed(TreeViewItem item)
 {
     return(false);
 }
 public override bool CanBeMultiSelected(TreeViewItem item)
 {
     return (ProjectBrowser.GetItemType(item.id) != ProjectBrowser.ItemType.SavedFilter);
 }
 public override bool IsExpandable(TreeViewItem item)
 {
     return (item.hasChildren && ((item != base.m_RootItem) || base.rootIsCollapsable));
 }
예제 #6
0
 public bool IsItemDragSelectedOrSelected(TreeViewItem item)
 {
     return((this.m_DragSelection.Count <= 0) ? this.state.selectedIDs.Contains(item.id) : this.m_DragSelection.Contains(item.id));
 }
 public override int GetNumRowsOnPageUpDown(TreeViewItem fromItem, bool pageUp, float heightOfTreeView)
 {
     return((int)Mathf.Floor(heightOfTreeView / this.k_LineHeight) - 1);
 }
예제 #8
0
 public abstract void OnRowGUI(Rect rowRect, TreeViewItem item, int row, bool selected, bool focused);
예제 #9
0
 protected virtual float AddSpaceBefore(TreeViewItem item)
 {
     return(0f);
 }
예제 #10
0
 public int GetNumRowsOnPageUpDown(TreeViewItem fromItem, bool pageUp, float heightOfTreeView)
 {
     Debug.LogError("GetNumRowsOnPageUpDown: Not impemented");
     return((int)Mathf.Floor(heightOfTreeView / 30f));
 }
예제 #11
0
 protected virtual Vector2 GetSizeOfRow(TreeViewItem item)
 {
     return(new Vector2(this.m_TreeView.GetTotalRect().width, 16f));
 }
        // Returns true if input gameobject or any of its descendants have modifications, otherwise returns false.
        bool AddTreeViewItemRecursive(TreeViewItem parentItem, GameObject gameObject, Dictionary <int, PrefabOverrides> prefabOverrideMap, IdSequence idSequence)
        {
            var gameObjectItem = new PrefabOverridesTreeViewItem
                                 (
                idSequence.get(),
                parentItem.depth + 1,
                gameObject.name
                                 );

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

            PrefabOverrides objectModifications;

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

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

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

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

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

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

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

            return(false);
        }
예제 #13
0
 override public int GetNumRowsOnPageUpDown(TreeViewItem fromItem, bool pageUp, float heightOfTreeView)
 {
     return((int)Mathf.Floor(heightOfTreeView / k_LineHeight) - 1); // -1 is fast fix for space between roots
 }
예제 #14
0
        public override DragAndDropVisualMode DoDrag(TreeViewItem parentItem, TreeViewItem targetItem, bool perform, DropPosition dropPos)
        {
            if (targetItem == null)
            {
                return(DragAndDropVisualMode.None);
            }

            object savedFilterData = DragAndDrop.GetGenericData(ProjectWindowUtil.k_DraggingFavoriteGenericData);

            // Dragging saved filter
            if (savedFilterData != null)
            {
                int instanceID = (int)savedFilterData;
                if (targetItem is SearchFilterTreeItem && parentItem is SearchFilterTreeItem)// && targetItem.id != draggedInstanceID && parentItem.id != draggedInstanceID)
                {
                    bool validMove = SavedSearchFilters.CanMoveSavedFilter(instanceID, parentItem.id, targetItem.id, dropPos == DropPosition.Below);
                    if (validMove && perform)
                    {
                        SavedSearchFilters.MoveSavedFilter(instanceID, parentItem.id, targetItem.id, dropPos == DropPosition.Below);
                        m_TreeView.SetSelection(new[] { instanceID }, false);
                        m_TreeView.NotifyListenersThatSelectionChanged();
                    }
                    return(validMove ? DragAndDropVisualMode.Copy : DragAndDropVisualMode.None);
                }
                return(DragAndDropVisualMode.None);
            }
            // Dragging of folders into filters
            else
            {
                // Check if we are dragging a single folder
                if (targetItem is SearchFilterTreeItem)
                {
                    string genericData = DragAndDrop.GetGenericData(ProjectWindowUtil.k_IsFolderGenericData) as string;
                    if (genericData == "isFolder")
                    {
                        if (perform)
                        {
                            Object[] objs = DragAndDrop.objectReferences;
                            if (objs.Length > 0)
                            {
                                string path = AssetDatabase.GetAssetPath(objs[0].GetInstanceID());
                                if (!string.IsNullOrEmpty(path))
                                {
                                    // TODO: Fix with new AssetDatabase API when it is ready (GetName)
                                    string       folderName   = new DirectoryInfo(path).Name;
                                    SearchFilter searchFilter = new SearchFilter();
                                    searchFilter.folders = new[] { path };
                                    bool addAsChild = targetItem == parentItem;

                                    float previewSize = ProjectBrowserColumnOneTreeViewGUI.GetListAreaGridSize();
                                    int   instanceID  = SavedSearchFilters.AddSavedFilterAfterInstanceID(folderName, searchFilter, previewSize, targetItem.id, addAsChild);
                                    m_TreeView.SetSelection(new[] { instanceID }, false);
                                    m_TreeView.NotifyListenersThatSelectionChanged();
                                }
                                else
                                {
                                    Debug.Log("Could not get asset path from id " + objs[0].GetInstanceID());
                                }
                            }
                        }
                        return(DragAndDropVisualMode.Copy); // Allow dragging folders to filters
                    }
                    return(DragAndDropVisualMode.None);     // Assets that are not folders are not allowed to be dragged to filters
                }
            }
            //  Assets are handled by base
            return(base.DoDrag(parentItem, targetItem, perform, dropPos));
        }
예제 #15
0
 internal static int GetItemControlID(TreeViewItem item)
 {
     return(((item == null) ? 0 : item.id) + 10000000);
 }
예제 #16
0
 public virtual void BeginPingNode(TreeViewItem item, float topPixelOfRow, float availableWidth)
 {
     throw new NotImplementedException();
 }
예제 #17
0
        public void HandleUnusedMouseEventsForNode(Rect rect, TreeViewItem item, bool firstItem)
        {
            int       itemControlID  = TreeView.GetItemControlID(item);
            Event     current        = Event.current;
            EventType typeForControl = current.GetTypeForControl(itemControlID);

            switch (typeForControl)
            {
            case EventType.MouseDown:
                if (rect.Contains(Event.current.mousePosition))
                {
                    if (Event.current.button == 0)
                    {
                        GUIUtility.keyboardControl = this.m_KeyboardControlID;
                        this.Repaint();
                        if (Event.current.clickCount == 2)
                        {
                            if (this.itemDoubleClickedCallback != null)
                            {
                                this.itemDoubleClickedCallback(item.id);
                            }
                        }
                        else
                        {
                            if (this.dragging == null || this.dragging.CanStartDrag(item, this.m_DragSelection, Event.current.mousePosition))
                            {
                                this.m_DragSelection = this.GetNewSelection(item, true, false);
                                DragAndDropDelay dragAndDropDelay = (DragAndDropDelay)GUIUtility.GetStateObject(typeof(DragAndDropDelay), itemControlID);
                                dragAndDropDelay.mouseDownPosition = Event.current.mousePosition;
                            }
                            GUIUtility.hotControl = itemControlID;
                        }
                        current.Use();
                    }
                    else if (Event.current.button == 1)
                    {
                        bool keepMultiSelection = true;
                        this.SelectionClick(item, keepMultiSelection);
                    }
                }
                return;

            case EventType.MouseUp:
                if (GUIUtility.hotControl == itemControlID)
                {
                    GUIUtility.hotControl = 0;
                    this.m_DragSelection.Clear();
                    current.Use();
                    if (rect.Contains(current.mousePosition))
                    {
                        float      contentIndent = this.gui.GetContentIndent(item);
                        Rect       rect2         = new Rect(rect.x + contentIndent, rect.y, rect.width - contentIndent, rect.height);
                        List <int> selectedIDs   = this.state.selectedIDs;
                        if (this.m_AllowRenameOnMouseUp && selectedIDs != null && selectedIDs.Count == 1 && selectedIDs[0] == item.id && rect2.Contains(current.mousePosition) && !EditorGUIUtility.HasHolddownKeyModifiers(current))
                        {
                            this.BeginNameEditing(0.5f);
                        }
                        else
                        {
                            this.SelectionClick(item, false);
                        }
                    }
                }
                return;

            case EventType.MouseMove:
IL_2D:
                if (typeForControl == EventType.DragUpdated || typeForControl == EventType.DragPerform)
                {
                    if (this.dragging != null && this.dragging.DragElement(item, rect, firstItem))
                    {
                        GUIUtility.hotControl = 0;
                    }
                    return;
                }
                if (typeForControl != EventType.ContextClick)
                {
                    return;
                }
                if (rect.Contains(current.mousePosition) && this.contextClickItemCallback != null)
                {
                    this.contextClickItemCallback(item.id);
                }
                return;

            case EventType.MouseDrag:
                if (GUIUtility.hotControl == itemControlID && this.dragging != null)
                {
                    DragAndDropDelay dragAndDropDelay2 = (DragAndDropDelay)GUIUtility.GetStateObject(typeof(DragAndDropDelay), itemControlID);
                    if (dragAndDropDelay2.CanStartDrag() && this.dragging.CanStartDrag(item, this.m_DragSelection, dragAndDropDelay2.mouseDownPosition))
                    {
                        this.dragging.StartDrag(item, this.m_DragSelection);
                        GUIUtility.hotControl = 0;
                    }
                    current.Use();
                }
                return;
            }
            goto IL_2D;
        }
예제 #18
0
 public virtual bool BeginRename(TreeViewItem item, float delay)
 {
     throw new NotImplementedException();
 }
예제 #19
0
        private void KeyboardGUI()
        {
            if (this.m_KeyboardControlID != GUIUtility.keyboardControl || !GUI.enabled)
            {
                return;
            }
            if (this.keyboardInputCallback != null)
            {
                this.keyboardInputCallback();
            }
            if (Event.current.type == EventType.KeyDown)
            {
                KeyCode keyCode = Event.current.keyCode;
                switch (keyCode)
                {
                case KeyCode.KeypadEnter:
                    goto IL_2FB;

                case KeyCode.KeypadEquals:
                case KeyCode.Insert:
                case KeyCode.F1:
IL_8E:
                    if (keyCode != KeyCode.Return)
                    {
                        if (Event.current.keyCode <= KeyCode.A || Event.current.keyCode < KeyCode.Z)
                        {
                        }
                        return;
                    }
                    goto IL_2FB;

                case KeyCode.UpArrow:
                    Event.current.Use();
                    this.OffsetSelection(-1);
                    return;

                case KeyCode.DownArrow:
                    Event.current.Use();
                    this.OffsetSelection(1);
                    return;

                case KeyCode.RightArrow:
                    foreach (int current in this.state.selectedIDs)
                    {
                        int          row;
                        TreeViewItem itemAndRowIndex = this.GetItemAndRowIndex(current, out row);
                        if (itemAndRowIndex != null)
                        {
                            if (this.data.IsExpandable(itemAndRowIndex) && !this.data.IsExpanded(itemAndRowIndex))
                            {
                                this.UserInputChangedExpandedState(itemAndRowIndex, row, true);
                            }
                            else if (this.state.selectedIDs.Count == 1)
                            {
                                this.HandleFastExpand(itemAndRowIndex, row);
                            }
                        }
                    }
                    Event.current.Use();
                    return;

                case KeyCode.LeftArrow:
                    foreach (int current2 in this.state.selectedIDs)
                    {
                        int          row2;
                        TreeViewItem itemAndRowIndex2 = this.GetItemAndRowIndex(current2, out row2);
                        if (itemAndRowIndex2 != null)
                        {
                            if (this.data.IsExpandable(itemAndRowIndex2) && this.data.IsExpanded(itemAndRowIndex2))
                            {
                                this.UserInputChangedExpandedState(itemAndRowIndex2, row2, false);
                            }
                            else if (this.state.selectedIDs.Count == 1)
                            {
                                this.HandleFastCollapse(itemAndRowIndex2, row2);
                            }
                        }
                    }
                    Event.current.Use();
                    return;

                case KeyCode.Home:
                    Event.current.Use();
                    this.OffsetSelection(-1000000);
                    return;

                case KeyCode.End:
                    Event.current.Use();
                    this.OffsetSelection(1000000);
                    return;

                case KeyCode.PageUp:
                {
                    Event.current.Use();
                    TreeViewItem treeViewItem = this.data.FindItem(this.state.lastClickedID);
                    if (treeViewItem != null)
                    {
                        int numRowsOnPageUpDown = this.gui.GetNumRowsOnPageUpDown(treeViewItem, true, this.m_TotalRect.height);
                        this.OffsetSelection(-numRowsOnPageUpDown);
                    }
                    return;
                }

                case KeyCode.PageDown:
                {
                    Event.current.Use();
                    TreeViewItem treeViewItem2 = this.data.FindItem(this.state.lastClickedID);
                    if (treeViewItem2 != null)
                    {
                        int numRowsOnPageUpDown2 = this.gui.GetNumRowsOnPageUpDown(treeViewItem2, true, this.m_TotalRect.height);
                        this.OffsetSelection(numRowsOnPageUpDown2);
                    }
                    return;
                }

                case KeyCode.F2:
                    if (Application.platform == RuntimePlatform.WindowsEditor && this.BeginNameEditing(0f))
                    {
                        Event.current.Use();
                    }
                    return;
                }
                goto IL_8E;
IL_2FB:
                if (Application.platform == RuntimePlatform.OSXEditor && this.BeginNameEditing(0f))
                {
                    Event.current.Use();
                }
            }
        }
예제 #20
0
 public virtual float GetContentIndent(TreeViewItem item)
 {
     return(this.GetFoldoutIndent(item) + this.m_FoldoutWidth);
 }
 private bool IsVisibleRootNode(TreeViewItem item)
 {
     return((this.m_TreeView.data as ProjectBrowserColumnOneTreeViewDataSource).IsVisibleRootNode(item));
 }
 public PackageExportTreeViewItem(ExportPackageItem itemIn, int id, int depth, TreeViewItem parent, string displayName)
     : base(id, depth, parent, displayName)
 {
     item = itemIn;
 }
 public override bool CanBeParent(TreeViewItem item)
 {
     return (!(item is SearchFilterTreeItem) || SavedSearchFilters.AllowsHierarchy());
 }
예제 #24
0
 private void SelectionByKey(TreeViewItem itemSelected)
 {
     this.state.selectedIDs   = this.GetNewSelection(itemSelected, false, true);
     this.state.lastClickedID = itemSelected.id;
     this.NotifyListenersThatSelectionChanged();
 }
 public bool IsVisibleRootNode(TreeViewItem item)
 {
     return ((item.parent != null) && (item.parent.parent == null));
 }
예제 #26
0
 public void SelectionClick(TreeViewItem itemClicked, bool keepMultiSelection)
 {
     this.state.selectedIDs   = this.GetNewSelection(itemClicked, keepMultiSelection, false);
     this.state.lastClickedID = ((itemClicked == null) ? 0 : itemClicked.id);
     this.NotifyListenersThatSelectionChanged();
 }
예제 #27
0
            override public void OnRowGUI(Rect rowRect, TreeViewItem tvItem, int row, bool selected, bool focused)
            {
                k_IndentWidth  = 18;
                k_FoldoutWidth = 18;
                const float k_ToggleWidth = 18f;

                var pitem = tvItem as PackageImportTreeViewItem;
                var item  = pitem.item;

                bool repainting = Event.current.type == EventType.Repaint;

                // 0. Selection row rect
                if (selected && repainting)
                {
                    selectionStyle.Draw(rowRect, false, false, true, focused);
                }

                bool validItem    = (item != null);
                bool isFolder     = (item != null) ? item.isFolder     : true;
                bool assetChanged = (item != null) ? item.assetChanged : false;
                bool pathConflict = (item != null) ? item.pathConflict : false;
                bool GUIDOverride = (item != null) ? item.existingAssetPath != string.Empty && item.existingAssetPath != item.destinationAssetPath : false;
                bool exists       = (item != null) ? item.exists       : true;
                bool projectAsset = (item != null) ? item.projectAsset : false;

                // 1. Foldout
                if (m_TreeView.data.IsExpandable(tvItem))
                {
                    DoFoldout(rowRect, tvItem, row);
                }

                // 2. Toggle only for items that are actually in the package.
                Rect toggleRect = new Rect(k_BaseIndent + tvItem.depth * indentWidth + k_FoldoutWidth, rowRect.y, k_ToggleWidth, rowRect.height);

                if ((isFolder && !projectAsset) || (validItem && !projectAsset && assetChanged))
                {
                    DoToggle(pitem, toggleRect);
                }

                using (new EditorGUI.DisabledScope(!validItem || projectAsset))
                {
                    // 3. Icon & Text
                    Rect contentRect = new Rect(toggleRect.xMax, rowRect.y, rowRect.width, rowRect.height);
                    DoIconAndText(tvItem, contentRect, selected, focused);

                    // 4. Preview popup
                    DoPreviewPopup(pitem, rowRect);

                    // 4. Warning about file/GUID clashing.
                    if (repainting && validItem)
                    {
                        if (pathConflict)
                        {
                            Rect labelRect = new Rect(rowRect.xMax - 58, rowRect.y, rowRect.height, rowRect.height);
                            EditorGUIUtility.SetIconSize(new Vector2(rowRect.height, rowRect.height));
                            GUI.Label(labelRect, Constants.badgeWarnPathConflict, Constants.paddinglessStyle);
                            EditorGUIUtility.SetIconSize(Vector2.zero);
                        }
                        else if (GUIDOverride)
                        {
                            Rect labelRect = new Rect(rowRect.xMax - 58, rowRect.y, rowRect.height, rowRect.height);
                            EditorGUIUtility.SetIconSize(new Vector2(rowRect.height, rowRect.height));
                            GUIContent badgeWarnGUIDConflict = EditorGUIUtility.TrIconContent("console.warnicon", "Warning: A file exists in this project with the same GUID. This Asset being imported will be assigned a new GUID. References to the asset being imported in other imported Assets will be replaced with a reference to: " + item.existingAssetPath);
                            GUI.Label(labelRect, badgeWarnGUIDConflict, Constants.paddinglessStyle);
                            EditorGUIUtility.SetIconSize(Vector2.zero);
                        }
                    }

                    // 5. Optional badge ("New")
                    if (repainting && validItem && !(exists || pathConflict))
                    {
                        // FIXME: Need to enable tooltips here.
                        Texture badge     = Constants.badgeNew.image;
                        Rect    labelRect = new Rect(rowRect.xMax - badge.width - 6, rowRect.y, badge.width, badge.height);
                        GUI.Label(labelRect, Constants.badgeNew, Constants.paddinglessStyle);
                    }

                    // 7. Show what stuff has changed
                    if (repainting && validItem && (exists || pathConflict) && assetChanged)
                    {
                        if (PackageImportWizard.instance.IsProjectSettingStep)
                        {
                            Texture badge     = Constants.badgeOverride.image;
                            Rect    labelRect = new Rect(rowRect.xMax - badge.width - 6, rowRect.y, badge.width, badge.height);
                            GUI.Label(labelRect, Constants.badgeOverride, Constants.paddinglessStyle);
                        }
                        else
                        {
                            Texture badge     = Constants.badgeChange.image;
                            Rect    labelRect = new Rect(rowRect.xMax - badge.width - 6, rowRect.y, rowRect.height, rowRect.height);
                            GUI.Label(labelRect, Constants.badgeChange, Constants.paddinglessStyle);
                        }
                    }
                }
            }
예제 #28
0
 public void UserExpandedNode(TreeViewItem item)
 {
 }
예제 #29
0
            TreeViewItem EnsureFolderPath(string folderPath, Dictionary <string, TreeViewItem> treeViewFolders, bool initExpandedState)
            {
                //We're in the root folder, so just return the root item as the parent.
                if (folderPath == "")
                {
                    return(m_RootItem);
                }

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

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

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

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

                    currentPath += folder;

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

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

                    id = currentPath.GetHashCode();

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

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

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

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

                return(currentItem);
            }
예제 #30
0
 public bool IsVisibleRootNode(TreeViewItem item)
 {
     // The main root Item is invisible the next level is visible root items
     return(item.parent != null && item.parent.parent == null);
 }