Exemple #1
0
 private void DrawRow(string label)
 {
     lastSelectedRow = new ListTreeViewItem <ReferencesTreeElement>(0, 0, label, null)
     {
         depth = 0,
         id    = 1
     };
     UpdateTreeModel();
     DrawReferencesPanel();
 }
Exemple #2
0
        private HierarchyReferenceItem[] GetTreeElementsFromRow(MaintainerTreeViewItem <ProjectReferenceItem> item)
        {
            var data    = item.data;
            var entries = data != null ? data.referencingEntries : null;

            int count;

            if (entries != null && entries.Length > 0)
            {
                count = entries.Length + 1;
            }
            else
            {
                count = 2;
            }

            var result = new HierarchyReferenceItem[count];

            result[0] = new HierarchyReferenceItem
            {
                id    = 0,
                name  = "root",
                depth = -1
            };

            if (entries == null || entries.Length == 0)
            {
                result[1] = new HierarchyReferenceItem
                {
                    id        = 1,
                    reference = null,
                    name      = item.displayName
                };

                return(result);
            }

            for (var i = 0; i < entries.Length; i++)
            {
                var entry   = entries[i];
                var newItem = new HierarchyReferenceItem
                {
                    id        = i + 1,
                    reference = entry
                };
                newItem.SetAssetPath(item.data.assetPath);
                result[i + 1] = newItem;
            }

            return(result);
        }
Exemple #3
0
        private ExactReferencesListElement[] GetTreeElementsFromRow(MaintainerTreeViewItem <ReferencesTreeElement> item)
        {
            var data    = item.data;
            var entries = data != null ? data.referencingEntries : null;

            int count;

            if (entries != null && entries.Length > 0)
            {
                count = entries.Length + 1;
            }
            else
            {
                count = 2;
            }

            var result = new ExactReferencesListElement[count];

            result[0] = new ExactReferencesListElement
            {
                id    = 0,
                name  = "root",
                depth = -1
            };

            if (entries == null || entries.Length == 0)
            {
                result[1] = new ExactReferencesListElement
                {
                    id    = 1,
                    entry = null,
                    name  = item.displayName
                };

                return(result);
            }

            for (var i = 0; i < entries.Length; i++)
            {
                var entry = entries[i];
                result[i + 1] = new ExactReferencesListElement
                {
                    id        = i + 1,
                    entry     = entry,
                    assetPath = item.data.assetPath
                };
            }

            return(result);
        }
Exemple #4
0
        internal virtual void Draw(MaintainerTreeViewItem <ReferencesTreeElement> selectedRow)
        {
            if (selectedRow == null)
            {
                DrawRow("Please select any child item above to look for exact references location.");
                return;
            }

            if (selectedRow.data == null)
            {
                DrawRow("Selected item has no exact references support.");
                return;
            }

            var entries = selectedRow.data.referencingEntries;

            if (entries == null || entries.Length == 0)
            {
                if (selectedRow.data.depth == 0)
                {
                    DrawRow("Please select any child item above to look for exact references location.");
                    return;
                }

                DrawRow("Selected item has no exact references support.");
                return;
            }

            if (lastSelectedRow != selectedRow)
            {
                lastSelectedRow = selectedRow;
                UpdateTreeModel();
            }

            DrawReferencesPanel();
        }
Exemple #5
0
        protected void SelectRowInternal(MaintainerTreeViewItem <T> rowLocal)
        {
            EditorApplication.delayCall += () =>
            {
                var id = rowLocal.id;
                SetExpanded(id, true);

                var childId = -1;
                if (rowLocal.data.HasChildren && rowLocal.data.Children.Count > 0)
                {
                    var child = rowLocal.data.Children[0];
                    childId = child.id;
                }

                FrameItem(childId > -1 ? childId : id);

                SetSelection(new List <int> {
                    id
                });
                SetFocusAndEnsureSelectedItem();

                MaintainerWindow.RepaintInstance();
            };
        }
Exemple #6
0
        protected override void DrawCell(ref Rect cellRect, MaintainerTreeViewItem <T> genericItem, int columnValue, RowGUIArgs args)
        {
            base.DrawCell(ref cellRect, genericItem, columnValue, args);

            var column = (Columns)columnValue;
            var item   = (HierarchyReferencesTreeViewItem <T>)genericItem;

            switch (column)
            {
            case Columns.Icon:

                if (item.depth == 0)
                {
                    if (item.icon != null)
                    {
                        var iconRect = cellRect;
                        iconRect.width  = IconWidth;
                        iconRect.height = EditorGUIUtility.singleLineHeight;

                        GUI.DrawTexture(iconRect, item.icon, ScaleMode.ScaleToFit);
                    }
                }

                break;

            case Columns.GameObject:

                var entryRect = cellRect;
                entryRect.xMin += baseIndent + UIHelpers.EyeButtonPadding;

                if (item.depth == 1)
                {
                    if (item.icon != null)
                    {
                        var iconRect = entryRect;
                        iconRect.xMin  -= UIHelpers.EyeButtonSize - UIHelpers.EyeButtonPadding;
                        iconRect.width  = IconWidth;
                        iconRect.x     += IconPadding;
                        iconRect.height = EditorGUIUtility.singleLineHeight;

                        GUI.DrawTexture(iconRect, item.icon, ScaleMode.ScaleToFit);
                    }
                }
                else
                {
                    /*entryRect.xMin += baseIndent + UIHelpers.EyeButtonPadding;*/
                }

                Rect lastRect;
                var  eyeButtonRect = entryRect;
                eyeButtonRect.xMin  += IconPadding;
                eyeButtonRect.width  = UIHelpers.EyeButtonSize;
                eyeButtonRect.height = UIHelpers.EyeButtonSize;
                eyeButtonRect.x     += UIHelpers.EyeButtonPadding;

                lastRect = eyeButtonRect;

                if (UIHelpers.IconButton(eyeButtonRect, CSIcons.Show))
                {
                    ShowItem(item);
                }

                var labelRect = entryRect;
                labelRect.xMin = lastRect.xMax + UIHelpers.EyeButtonPadding;

                if (item.data.depth == 0 && !item.data.HasChildren)
                {
                    GUI.contentColor = CSColors.labelDimmedColor;
                }
                DefaultGUI.Label(labelRect, args.label, args.selected, args.focused);

                GUI.contentColor = Color.white;
                break;

            case Columns.Component:

                var componentName = item.data.reference.componentName;
                if (!string.IsNullOrEmpty(componentName))
                {
                    DefaultGUI.Label(cellRect, componentName, args.selected, args.focused);
                }

                break;

            case Columns.Property:

                var propertyPath = item.data.reference.propertyPath;
                if (!string.IsNullOrEmpty(propertyPath))
                {
                    DefaultGUI.Label(cellRect, propertyPath, args.selected, args.focused);
                }

                break;

            case Columns.ReferencesCount:

                if (item.depth == 0)
                {
                    DefaultGUI.Label(cellRect, item.data.ChildrenCount.ToString(), args.selected, args.focused);
                }

                break;

            default:
                throw new ArgumentOutOfRangeException("column", column, null);
            }
        }
Exemple #7
0
        protected override void DrawCell(ref Rect cellRect, MaintainerTreeViewItem <T> genericItem, int columnValue, RowGUIArgs args)
        {
            base.DrawCell(ref cellRect, genericItem, columnValue, args);

            var column = (Columns)columnValue;
            var item   = (ProjectReferencesTreeViewItem <T>)genericItem;

            switch (column)
            {
            case Columns.Path:

                var entryRect = DrawIconAndGetEntryRect(cellRect, item);

                Rect lastRect;

                var eyeButtonRect = entryRect;
                eyeButtonRect.width  = UIHelpers.EyeButtonSize;
                eyeButtonRect.height = UIHelpers.EyeButtonSize;
                eyeButtonRect.x     += UIHelpers.EyeButtonPadding;

                lastRect = eyeButtonRect;

                if (UIHelpers.IconButton(eyeButtonRect, CSIcons.Show))
                {
                    ShowItem(item);
                }

                if (item.depth == 1 && item.data.isReferenced)
                {
                    var findButtonRect = entryRect;
                    findButtonRect.width  = UIHelpers.EyeButtonSize;
                    findButtonRect.height = UIHelpers.EyeButtonSize;
                    findButtonRect.x     += UIHelpers.EyeButtonPadding * 2 + UIHelpers.EyeButtonSize;

                    lastRect = findButtonRect;

                    if (UIHelpers.IconButton(findButtonRect, CSIcons.Find, "Search for references"))
                    {
                        EditorApplication.delayCall += () => ProjectScopeReferencesFinder.FindAssetReferencesFromResults(item.data.assetPath);
                    }
                }

                var labelRect = entryRect;
                labelRect.xMin = lastRect.xMax + UIHelpers.EyeButtonPadding;

                if (item.data.depth == 0 && !item.data.HasChildren)
                {
                    GUI.contentColor = CSColors.labelDimmedColor;
                }
                DefaultGUI.Label(labelRect, args.label, args.selected, args.focused);

                GUI.contentColor = Color.white;

                break;

            case Columns.Type:

                DefaultGUI.Label(cellRect, item.data.assetTypeName, args.selected, args.focused);
                break;

            case Columns.Size:

                DefaultGUI.Label(cellRect, item.data.assetSizeFormatted, args.selected, args.focused);
                break;

            case Columns.ReferencesCount:

                if (item.depth == 0)
                {
                    DefaultGUI.Label(cellRect, item.data.ChildrenCount.ToString(), args.selected, args.focused);
                }
                break;

            default:
                throw new ArgumentOutOfRangeException("column", column, null);
            }
        }
Exemple #8
0
 protected virtual void DrawCell(ref Rect cellRect, MaintainerTreeViewItem <T> genericItem, int columnValue, RowGUIArgs args)
 {
     baseIndent = genericItem.depth * GetDepthIndentation();
     CenterRectUsingSingleLineHeight(ref cellRect);
 }