private void OnGUI()
        {
            UIHelpers.SetupStyles();

            EditorGUI.BeginChangeCheck();
            currentTab = GUILayout.Toolbar(currentTab, tabs, GUILayout.ExpandWidth(false));
            if (EditorGUI.EndChangeCheck())
            {
                MaintainerSettings.Instance.selectedTabIndex = currentTab;
                EditorUtility.SetDirty(MaintainerSettings.Instance);
            }

            if (currentTab == 0)
            {
                IssuesTab.Draw(this);
            }
            else if (currentTab == 1)
            {
                AboutTab.Draw(this);
            }
        }
Exemplo n.º 2
0
        private static bool DrawSettingsSearchSectionHeader(SettingsSearchSection section, ref bool foldout)
        {
            GUILayout.Space(5);
            using (new GUILayout.HorizontalScope())
            {
                foldout = EditorGUI.Foldout(EditorGUILayout.GetControlRect(true, GUILayout.Width(165)), foldout, ObjectNames.NicifyVariableName(section.ToString()), true, UIHelpers.richFoldout);

                if (UIHelpers.IconButton(CSIcons.SelectAll))
                {
                    SettingsSectionGroupSwitch(section, true);
                }

                if (UIHelpers.IconButton(CSIcons.SelectNone))
                {
                    SettingsSectionGroupSwitch(section, false);
                }
            }
            UIHelpers.Separator();

            return(foldout);
        }
Exemplo n.º 3
0
        public static void Draw(ref Vector2 settingsSectionScrollPosition)
        {
            // ----------------------------------------------------------------------------
            // filtering settings
            // ----------------------------------------------------------------------------

            if (UIHelpers.ImageButton("Manage Filters...", CSIcons.Gear))
            {
                IssuesFiltersWindow.Create();
            }

            GUILayout.Space(5);
            DrawWhereSection(ref settingsSectionScrollPosition);
            GUILayout.Space(5);
            DrawWhatSection(ref settingsSectionScrollPosition);

            if (UIHelpers.ImageButton("Reset", "Resets settings to defaults.", CSIcons.Restore))
            {
                MaintainerSettings.Issues.Reset();
            }
        }
Exemplo n.º 4
0
        protected override void DrawRecord(int recordIndex, out bool recordRemoved)
        {
            recordRemoved = false;
            RecordBase    record        = records[recordIndex];
            CleanerRecord cleanerRecord = record as CleanerRecord;

            if (cleanerRecord == null)
            {
                GUILayout.Label("Incorrect record! Please report this to support.");
                return;
            }

            // hide cleaned records
            if (cleanerRecord.cleaned)
            {
                return;
            }

            UIHelpers.Separator();

            using (UIHelpers.Horizontal())
            {
                DrawRecordCheckbox(cleanerRecord);

                using (UIHelpers.Vertical())
                {
                    /* header */
                    using (UIHelpers.Horizontal())
                    {
                        DrawSeverityIcon(record);
                        GUILayout.Label(record.GetHeader(), UIHelpers.richLabel, GUILayout.ExpandWidth(false));
                    }

                    /* body */
                    GUILayout.Label(record.GetBody(), UIHelpers.richLabel);

                    DrawRecordButtons(record);
                }
            }
        }
Exemplo n.º 5
0
        private void DrawMoreButton(AssetRecord assetRecord)
        {
            if (UIHelpers.RecordButton(assetRecord, "Shows menu with additional actions for this record.", CSIcons.More))
            {
                GenericMenu menu = new GenericMenu();
                if (!string.IsNullOrEmpty(assetRecord.path))
                {
                    menu.AddItem(new GUIContent("Ignore/Add path to ignores"), false, () =>
                    {
                        if (CSArrayTools.AddIfNotExists(ref MaintainerSettings.Cleaner.pathIgnores, assetRecord.assetDatabasePath))
                        {
                            MaintainerWindow.ShowNotification("Ignore added: " + assetRecord.assetDatabasePath);
                            CleanerFiltersWindow.Refresh();
                        }
                        else
                        {
                            MaintainerWindow.ShowNotification("Such item already added to the ignores!");
                        }
                    });

                    DirectoryInfo dir = Directory.GetParent(assetRecord.assetDatabasePath);
                    if (dir.Name != "Assets")
                    {
                        menu.AddItem(new GUIContent("Ignore/Add parent directory to ignores"), false, () =>
                        {
                            if (CSArrayTools.AddIfNotExists(ref MaintainerSettings.Cleaner.pathIgnores, dir.ToString()))
                            {
                                MaintainerWindow.ShowNotification("Ignore added: " + dir);
                                CleanerFiltersWindow.Refresh();
                            }
                            else
                            {
                                MaintainerWindow.ShowNotification("Such item already added to the ignores!");
                            }
                        });
                    }
                }
                menu.ShowAsContext();
            }
        }
Exemplo n.º 6
0
        private void OnGUI()
        {
            UIHelpers.SetupStyles();

            EditorGUI.BeginChangeCheck();
            currentTab = (MaintainerTab)GUILayout.Toolbar((int)currentTab, tabsCaptions, GUILayout.ExpandWidth(false), GUILayout.Height(21));
            if (EditorGUI.EndChangeCheck())
            {
                if (currentTab == MaintainerTab.Cleaner)
                {
                    ShowProjectCleanerWarning();
                }
                MaintainerPersonalSettings.Instance.selectedTab = currentTab;

                Refresh(false);
            }

            switch (currentTab)
            {
            case MaintainerTab.Issues:
                issuesTab.Draw();
                break;

            case MaintainerTab.Cleaner:
                cleanerTab.Draw();
                break;

            case MaintainerTab.References:
                referencesTab.Draw();
                break;

            case MaintainerTab.About:
                aboutTab.Draw();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemplo n.º 7
0
        /* protected methods */

        protected void DrawShowButtonIfPossible(T record)
        {
            var showableIssueRecord = record as IShowableRecord;

            if (showableIssueRecord == null)
            {
                return;
            }

            string hintText;

            switch (record.Location)
            {
            case RecordLocation.Unknown:
                hintText = "Oh, sorry, but looks like I have no clue about this record.";
                break;

            case RecordLocation.Scene:
                hintText = "Selects item in the scene. Opens scene with target item if necessary and highlights this scene in the Project Browser.";
                break;

            case RecordLocation.Asset:
                hintText = "Selects asset file in the Project Browser or opens settings asset.";
                break;

            case RecordLocation.Prefab:
                hintText = "Selects Prefab file with item in the Project Browser.";
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (UIHelpers.RecordButton(record, "Show", hintText, CSIcons.Show))
            {
                gotoRecord = showableIssueRecord;
            }
        }
Exemplo n.º 8
0
        protected override void DrawLeftColumnHeader()
        {
            using (new GUILayout.HorizontalScope())
            {
                GUILayout.Space(10);
                using (new GUILayout.VerticalScope())
                {
                    GUILayout.Space(10);
                    if (UIHelpers.ImageButton("1. Scan Project", CSIcons.Find))
                    {
                        EditorApplication.delayCall += StartSearch;
                    }

                    GUILayout.Space(5);

                    if (UIHelpers.ImageButton("2. Fix fixable selected issues", CSIcons.AutoFix))
                    {
                        EditorApplication.delayCall += StartFix;
                    }
                    GUILayout.Space(10);
                }
                GUILayout.Space(10);
            }
        }
Exemplo n.º 9
0
        protected override void DrawLeftColumnHeader()
        {
            base.DrawLeftColumnHeader();

            using (new GUILayout.HorizontalScope())
            {
                GUILayout.Space(10);
                using (new GUILayout.VerticalScope())
                {
                    GUILayout.Space(10);
                    if (UIHelpers.ImageButton("1. Scan Project", CSIcons.Find))
                    {
                        EditorApplication.delayCall += StartSearch;
                    }
                    GUILayout.Space(5);
                    if (UIHelpers.ImageButton("2. Delete selected garbage", CSIcons.Delete))
                    {
                        EditorApplication.delayCall += StartClean;
                    }
                    GUILayout.Space(10);
                }
                GUILayout.Space(10);
            }
        }
Exemplo n.º 10
0
        private void DrawDeleteButton(CleanerRecord record, int recordIndex)
        {
            if (UIHelpers.RecordButton(record, "Delete", "Deletes this single item.", CSIcons.Delete))
            {
                if (!MaintainerPersonalSettings.Cleaner.deletionPromptShown)
                {
                    MaintainerPersonalSettings.Cleaner.deletionPromptShown = true;
                    if (!EditorUtility.DisplayDialog(
                            ProjectCleaner.ModuleName,
                            "Please note, this action will physically remove asset file from the project! Are you sure you wish to do this?\n" +
                            "Author is not responsible for any damage made due to the module usage!\n" +
                            "This message shows only once.",
                            "Yes", "No"))
                    {
                        return;
                    }
                }

                if (record.Clean())
                {
                    DeleteRecords(new[] { recordIndex });
                }
            }
        }
Exemplo n.º 11
0
        public static void Draw(ref Vector2 settingsSectionScrollPosition)
        {
            // -----------------------------------------------------------------------------
            // filtering settings
            // -----------------------------------------------------------------------------

            DrawWhereSection();

            GUILayout.Space(5);
            DrawWhatSection(ref settingsSectionScrollPosition);
            GUILayout.Space(10);

            using (new GUILayout.HorizontalScope())
            {
                GUILayout.Space(10);
                if (UIHelpers.ImageButton("Reset Settings", "Resets settings to defaults.", CSIcons.Restore))
                {
                    ProjectSettings.Issues.Reset();
                    UserSettings.Issues.Reset();
                }
                GUILayout.Space(10);
            }
            GUILayout.Space(10);
        }
Exemplo n.º 12
0
        private static void DrawWhatSection(ref Vector2 settingsSectionScrollPosition)
        {
            // -----------------------------------------------------------------------------
            // what to look for
            // -----------------------------------------------------------------------------

            using (new GUILayout.VerticalScope(/*UIHelpers.panelWithBackground*/))
            {
                DrawSettingsSearchSectionHeader(SettingsSearchSection.All, "<b><size=16>What</size></b>");
                settingsSectionScrollPosition = GUILayout.BeginScrollView(settingsSectionScrollPosition, GUIStyle.none, GUI.skin.verticalScrollbar);

                using (new GUILayout.HorizontalScope())
                {
                    GUILayout.Space(10);

                    using (new GUILayout.VerticalScope())
                    {
                        GUILayout.Space(10);

                        // -----------------------------------------------------------------------------
                        // Common Issues
                        // -----------------------------------------------------------------------------

                        ProjectSettings.Issues.missingReferences = EditorGUILayout.ToggleLeft(new GUIContent("Missing references", "Search for any missing references in Components, Project Settings, Scriptable Objects, and so on."), ProjectSettings.Issues.missingReferences);

#if UNITY_2019_1_OR_NEWER
                        ProjectSettings.Issues.shadersWithErrors = EditorGUILayout.ToggleLeft(new GUIContent("Shaders errors", "Search for shaders with compilation errors."), ProjectSettings.Issues.shadersWithErrors);
#endif
                        UIHelpers.Separator(5);

                        // -----------------------------------------------------------------------------
                        // Game Object Issues
                        // -----------------------------------------------------------------------------

                        using (new GUILayout.VerticalScope(UIHelpers.panelWithBackground))
                        {
                            UIHelpers.Foldout(ref UserSettings.Issues.gameObjectsFoldout, "<b>Game Object Issues</b>");
                        }

                        if (UserSettings.Issues.gameObjectsFoldout)
                        {
                            GUILayout.Space(-2);
                            UIHelpers.IndentLevel();
                            if (DrawSettingsFoldoutSectionHeader(SettingsSearchSection.Common, ref UserSettings.Issues.commonFoldout))
                            {
                                UIHelpers.IndentLevel();
                                ProjectSettings.Issues.missingComponents       = EditorGUILayout.ToggleLeft(new GUIContent("Missing components", "Search for the missing components on the Game Objects."), ProjectSettings.Issues.missingComponents);
                                ProjectSettings.Issues.missingPrefabs          = EditorGUILayout.ToggleLeft(new GUIContent("Missing prefabs", "Search for instances of prefabs which were removed from project."), ProjectSettings.Issues.missingPrefabs);
                                ProjectSettings.Issues.duplicateComponents     = EditorGUILayout.ToggleLeft(new GUIContent("Duplicate components", "Search for the multiple instances of the same component with same values on the same object."), ProjectSettings.Issues.duplicateComponents);
                                ProjectSettings.Issues.inconsistentTerrainData = EditorGUILayout.ToggleLeft(new GUIContent("Inconsistent Terrain Data", "Search for Game Objects where Terrain and TerrainCollider have different Terrain Data."), ProjectSettings.Issues.inconsistentTerrainData);
                                UIHelpers.UnIndentLevel();
                            }

                            if (DrawSettingsFoldoutSectionHeader(SettingsSearchSection.Neatness, ref UserSettings.Issues.neatnessFoldout))
                            {
                                UIHelpers.IndentLevel();
                                ProjectSettings.Issues.unnamedLayers = EditorGUILayout.ToggleLeft(new GUIContent("Objects with unnamed layers", "Search for GameObjects with unnamed layers."), ProjectSettings.Issues.unnamedLayers);
                                ProjectSettings.Issues.hugePositions = EditorGUILayout.ToggleLeft(new GUIContent("Objects with huge positions", "Search for GameObjects with huge world positions (> |100 000| on any axis)."), ProjectSettings.Issues.hugePositions);
                                UIHelpers.UnIndentLevel();
                            }
                            UIHelpers.UnIndentLevel();
                            GUILayout.Space(5);
                        }

                        GUI.enabled = true;

                        // -----------------------------------------------------------------------------
                        // Project Settings Issues
                        // -----------------------------------------------------------------------------

                        using (new GUILayout.VerticalScope(UIHelpers.panelWithBackground))
                        {
                            UIHelpers.Foldout(ref UserSettings.Issues.projectSettingsFoldout, "<b>Project Settings Issues</b>");
                        }

                        if (UserSettings.Issues.projectSettingsFoldout)
                        {
                            UIHelpers.IndentLevel();
                            ProjectSettings.Issues.duplicateLayers = EditorGUILayout.ToggleLeft(new GUIContent("Duplicate Layers", "Search for the duplicate layers and sorting layers at the 'Tags and Layers' Project Settings."), ProjectSettings.Issues.duplicateLayers);
                            UIHelpers.UnIndentLevel();
                        }
                        GUI.enabled = true;

                        GUILayout.Space(10);
                    }
                    GUILayout.Space(10);
                }
                GUILayout.EndScrollView();
            }
        }
Exemplo n.º 13
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);
            }
        }
Exemplo n.º 14
0
        protected override void DrawSettingsBody()
        {
            // ----------------------------------------------------------------------------
            // filtering settings
            // ----------------------------------------------------------------------------

            using (layout.Vertical(UIHelpers.panelWithBackground))
            {
                GUILayout.Space(5);

                if (UIHelpers.ImageButton("Manage Filters...", CSIcons.Gear))
                {
                    IssuesFiltersWindow.Create();
                }

                GUILayout.Space(5);

                /* Game Object Issues filtering */

                GUILayout.Label("<b><size=12>Game Object Issues filtering</size></b>", UIHelpers.richLabel);
                UIHelpers.Separator();
                GUILayout.Space(5);

                using (layout.Horizontal())
                {
                    MaintainerSettings.Issues.lookInScenes = EditorGUILayout.ToggleLeft(new GUIContent("Scenes", "Uncheck to exclude all scenes from search or select filtering level:\n\n" +
                                                                                                       "All Scenes: all project scenes with respect to configured filters.\n" +
                                                                                                       "Included Scenes: scenes included via Manage Filters > Scene Includes.\n" +
                                                                                                       "Current Scene: currently opened scene including any additional loaded scenes."), MaintainerSettings.Issues.lookInScenes, GUILayout.Width(70));
                    GUI.enabled = MaintainerSettings.Issues.lookInScenes;
                    MaintainerSettings.Issues.scenesSelection = (IssuesFinderSettings.ScenesSelection)EditorGUILayout.EnumPopup(MaintainerSettings.Issues.scenesSelection);
                    GUI.enabled = true;
                }

                MaintainerSettings.Issues.lookInAssets             = EditorGUILayout.ToggleLeft(new GUIContent("Prefab assets", "Uncheck to exclude all prefab assets files from the search. Check readme for additional details."), MaintainerSettings.Issues.lookInAssets);
                MaintainerSettings.Issues.touchInactiveGameObjects = EditorGUILayout.ToggleLeft(new GUIContent("Inactive GameObjects", "Uncheck to exclude all inactive Game Objects from the search."), MaintainerSettings.Issues.touchInactiveGameObjects);
                MaintainerSettings.Issues.touchDisabledComponents  = EditorGUILayout.ToggleLeft(new GUIContent("Disabled Components", "Uncheck to exclude all disabled Components from the search."), MaintainerSettings.Issues.touchDisabledComponents);

                GUILayout.Space(2);
            }

            using (layout.Vertical(UIHelpers.panelWithBackground, GUILayout.ExpandHeight(true)))
            {
                GUILayout.Space(5);
                GUILayout.Label("<b><size=12>Search for:</size></b>", UIHelpers.richLabel);

                settingsSectionScrollPosition = GUILayout.BeginScrollView(settingsSectionScrollPosition, GUIStyle.none, GUI.skin.verticalScrollbar);

                // ----------------------------------------------------------------------------
                // Game Object Issues
                // ----------------------------------------------------------------------------

                GUI.enabled = UIHelpers.ToggleFoldout(ref MaintainerSettings.Issues.scanGameObjects, ref MaintainerSettings.Issues.gameObjectsFoldout, new GUIContent("<b>Game Object Issues</b>", "Group of issues related to the Game Objects."));
                if (MaintainerSettings.Issues.gameObjectsFoldout)
                {
                    GUILayout.Space(-2);
                    UIHelpers.Indent();

                    if (DrawSettingsSearchSectionHeader(SettingsSearchSection.Common, ref MaintainerSettings.Issues.commonFoldout))
                    {
                        MaintainerSettings.Issues.missingComponents   = EditorGUILayout.ToggleLeft(new GUIContent("Missing components", "Search for the missing components on the Game Objects."), MaintainerSettings.Issues.missingComponents);
                        MaintainerSettings.Issues.duplicateComponents = EditorGUILayout.ToggleLeft(new GUIContent("Duplicate components", "Search for the multiple instances of the same component with same values on the same object."), MaintainerSettings.Issues.duplicateComponents);

                        bool show = MaintainerSettings.Issues.duplicateComponents;
                        if (show)
                        {
                            EditorGUI.indentLevel++;
                            MaintainerSettings.Issues.duplicateComponentsPrecise = EditorGUILayout.ToggleLeft(new GUIContent("Precise mode", "Uncheck to ignore component's values."), MaintainerSettings.Issues.duplicateComponentsPrecise);
                            EditorGUI.indentLevel--;
                        }

                        MaintainerSettings.Issues.missingReferences       = EditorGUILayout.ToggleLeft(new GUIContent("Missing references", "Search for any missing references in the serialized fields of the components."), MaintainerSettings.Issues.missingReferences);
                        MaintainerSettings.Issues.undefinedTags           = EditorGUILayout.ToggleLeft(new GUIContent("Objects with undefined tags", "Search for GameObjects without any tag."), MaintainerSettings.Issues.undefinedTags);
                        MaintainerSettings.Issues.inconsistentTerrainData = EditorGUILayout.ToggleLeft(new GUIContent("Inconsistent Terrain Data", "Search for Game Objects where Terrain and TerrainCollider have different Terrain Data."), MaintainerSettings.Issues.inconsistentTerrainData);
                    }

                    if (DrawSettingsSearchSectionHeader(SettingsSearchSection.PrefabsSpecific, ref MaintainerSettings.Issues.prefabsFoldout))
                    {
                        MaintainerSettings.Issues.missingPrefabs      = EditorGUILayout.ToggleLeft(new GUIContent("Missing prefabs", "Search for instances of prefabs which were removed from project."), MaintainerSettings.Issues.missingPrefabs);
                        MaintainerSettings.Issues.disconnectedPrefabs = EditorGUILayout.ToggleLeft(new GUIContent("Disconnected prefabs", "Search for disconnected prefabs instances."), MaintainerSettings.Issues.disconnectedPrefabs);
                    }

                    if (DrawSettingsSearchSectionHeader(SettingsSearchSection.UnusedComponents, ref MaintainerSettings.Issues.unusedFoldout))
                    {
                        MaintainerSettings.Issues.emptyMeshColliders   = EditorGUILayout.ToggleLeft("MeshColliders w/o meshes", MaintainerSettings.Issues.emptyMeshColliders);
                        MaintainerSettings.Issues.emptyMeshFilters     = EditorGUILayout.ToggleLeft("MeshFilters w/o meshes", MaintainerSettings.Issues.emptyMeshFilters);
                        MaintainerSettings.Issues.emptyAnimations      = EditorGUILayout.ToggleLeft("Animations w/o clips", MaintainerSettings.Issues.emptyAnimations);
                        MaintainerSettings.Issues.emptyRenderers       = EditorGUILayout.ToggleLeft("Renders w/o materials", MaintainerSettings.Issues.emptyRenderers);
                        MaintainerSettings.Issues.emptySpriteRenderers = EditorGUILayout.ToggleLeft("SpriteRenders w/o sprites", MaintainerSettings.Issues.emptySpriteRenderers);
                        MaintainerSettings.Issues.emptyTerrainCollider = EditorGUILayout.ToggleLeft("TerrainColliders w/o Terrain Data", MaintainerSettings.Issues.emptyTerrainCollider);
                        MaintainerSettings.Issues.emptyAudioSource     = EditorGUILayout.ToggleLeft("AudioSources w/o AudioClips", MaintainerSettings.Issues.emptyAudioSource);
                    }

                    if (DrawSettingsSearchSectionHeader(SettingsSearchSection.Neatness, ref MaintainerSettings.Issues.neatnessFoldout))
                    {
                        MaintainerSettings.Issues.emptyArrayItems = EditorGUILayout.ToggleLeft(new GUIContent("Empty array items", "Look for any unused items in arrays."), MaintainerSettings.Issues.emptyArrayItems);
                        bool show = MaintainerSettings.Issues.emptyArrayItems;
                        if (show)
                        {
                            EditorGUI.indentLevel++;
                            MaintainerSettings.Issues.skipEmptyArrayItemsOnPrefabs = EditorGUILayout.ToggleLeft(new GUIContent("Skip prefab files", "Ignore empty array items in prefab files."), MaintainerSettings.Issues.skipEmptyArrayItemsOnPrefabs);
                            EditorGUI.indentLevel--;
                        }
                        MaintainerSettings.Issues.unnamedLayers = EditorGUILayout.ToggleLeft(new GUIContent("Objects with unnamed layers", "Search for GameObjects with unnamed layers."), MaintainerSettings.Issues.unnamedLayers);
                        MaintainerSettings.Issues.hugePositions = EditorGUILayout.ToggleLeft(new GUIContent("Objects with huge positions", "Search for GameObjects with huge world positions (> |100 000| on any axis)."), MaintainerSettings.Issues.hugePositions);
                    }

                    UIHelpers.UnIndent();
                }
                GUI.enabled = true;

                // ----------------------------------------------------------------------------
                // Project Settings Issues
                // ----------------------------------------------------------------------------

                GUI.enabled = UIHelpers.ToggleFoldout(ref MaintainerSettings.Issues.scanProjectSettings, ref MaintainerSettings.Issues.projectSettingsFoldout, new GUIContent("<b>Project Settings Issues</b>", "Group of issues related to the settings of the current project."));
                if (MaintainerSettings.Issues.projectSettingsFoldout)
                {
                    UIHelpers.Indent();

                    MaintainerSettings.Issues.duplicateScenesInBuild = EditorGUILayout.ToggleLeft(new GUIContent("Duplicate scenes in build", "Search for the duplicates at the 'Scenes In Build' section of the Build Settings."), MaintainerSettings.Issues.duplicateScenesInBuild);
                    MaintainerSettings.Issues.duplicateTagsAndLayers = EditorGUILayout.ToggleLeft(new GUIContent("Duplicates in Tags and Layers", "Search for the duplicate items at the 'Tags and Layers' Project Settings."), MaintainerSettings.Issues.duplicateTagsAndLayers);

                    UIHelpers.UnIndent();
                }
                GUI.enabled = true;

                GUILayout.EndScrollView();
                UIHelpers.Separator();

                using (layout.Horizontal())
                {
                    if (UIHelpers.ImageButton("Check all", CSIcons.SelectAll))
                    {
                        MaintainerSettings.Issues.SwitchAll(true);
                    }

                    if (UIHelpers.ImageButton("Uncheck all", CSIcons.SelectNone))
                    {
                        MaintainerSettings.Issues.SwitchAll(false);
                    }
                }
            }

            if (UIHelpers.ImageButton("Reset", "Resets settings to defaults.", CSIcons.Restore))
            {
                MaintainerSettings.Issues.Reset();
            }
        }
Exemplo n.º 15
0
        protected override void DrawRecord(int recordIndex)
        {
            IssueRecord record = filteredRecords[recordIndex];

            // hide fixed records
            if (record.@fixed)
            {
                return;
            }

            using (layout.Vertical())
            {
                if (recordIndex > 0 && recordIndex < filteredRecords.Length)
                {
                    UIHelpers.Separator();
                }

                using (layout.Horizontal())
                {
                    DrawRecordCheckbox(record);
                    DrawExpandCollapseButton(record);
                    DrawSeverityIcon(record);

                    if (record.compactMode)
                    {
                        DrawRecordButtons(record, recordIndex);
                        GUILayout.Label(record.GetCompactLine(), UIHelpers.richLabel);
                    }
                    else
                    {
                        GUILayout.Space(5);
                        GUILayout.Label(record.GetHeader(), UIHelpers.richLabel);
                    }

                    if (record.location == RecordLocation.Prefab)
                    {
                        GUILayout.Space(3);
                        UIHelpers.Icon(CSEditorTextures.PrefabIcon, "Issue found in the Prefab.");
                    }
                }

                if (!record.compactMode)
                {
                    UIHelpers.Separator();
                    using (layout.Horizontal())
                    {
                        GUILayout.Space(5);
                        GUILayout.Label(record.GetBody(), UIHelpers.richLabel);
                    }
                    using (layout.Horizontal())
                    {
                        GUILayout.Space(5);
                        DrawRecordButtons(record, recordIndex);
                    }
                    GUILayout.Space(3);
                }
            }

            if (Event.current != null && Event.current.type == EventType.MouseDown)
            {
                Rect guiRect = GUILayoutUtility.GetLastRect();
                guiRect.height += 2;                 // to compensate the separator's gap

                if (guiRect.Contains(Event.current.mousePosition))
                {
                    record.compactMode = !record.compactMode;
                    Event.current.Use();
                }
            }
        }
Exemplo n.º 16
0
        private void DrawMoreButton(AssetIssueRecord record)
        {
            if (!UIHelpers.RecordButton(record, "Shows menu with additional actions for this record.", CSIcons.More))
            {
                return;
            }

            var menu = new GenericMenu();

            if (!string.IsNullOrEmpty(record.Path))
            {
                menu.AddItem(new GUIContent("Ignore/Full Path"), false, () =>
                {
                    if (!CSFilterTools.IsValueMatchesAnyFilter(record.Path, ProjectSettings.Issues.pathIgnoresFilters))
                    {
                        var newFilter = FilterItem.Create(record.Path, FilterKind.Path);
                        ArrayUtility.Add(ref ProjectSettings.Issues.pathIgnoresFilters, newFilter);

                        ApplyNewIgnoreFilter(newFilter);

                        MaintainerWindow.ShowNotification("Ignore added: " + record.Path);
                        CleanerFiltersWindow.Refresh();
                    }
                    else
                    {
                        MaintainerWindow.ShowNotification("Already added to the ignores!");
                    }
                });

                var dir = Directory.GetParent(record.Path);
                if (!CSPathTools.IsAssetsRootPath(dir.FullName))
                {
                    menu.AddItem(new GUIContent("Ignore/Parent Folder"), false, () =>
                    {
                        var dirPath = CSPathTools.EnforceSlashes(dir.ToString());

                        if (!CSFilterTools.IsValueMatchesAnyFilter(dirPath, ProjectSettings.Issues.pathIgnoresFilters))
                        {
                            var newFilter = FilterItem.Create(dirPath, FilterKind.Directory);
                            ArrayUtility.Add(ref ProjectSettings.Issues.pathIgnoresFilters, newFilter);

                            ApplyNewIgnoreFilter(newFilter);

                            MaintainerWindow.ShowNotification("Ignore added: " + dirPath);
                            CleanerFiltersWindow.Refresh();
                        }
                        else
                        {
                            MaintainerWindow.ShowNotification("Already added to the ignores!");
                        }
                    });
                }
            }

            var objectIssue = record as GameObjectIssueRecord;

            if (objectIssue != null)
            {
                if (!string.IsNullOrEmpty(objectIssue.componentName))
                {
                    menu.AddItem(new GUIContent("Ignore/\"" + objectIssue.componentName + "\" Component"), false, () =>
                    {
                        if (!CSFilterTools.IsValueMatchesAnyFilter(objectIssue.componentName, ProjectSettings.Issues.componentIgnoresFilters))
                        {
                            var newFilter = FilterItem.Create(objectIssue.componentName, FilterKind.Type);
                            ArrayUtility.Add(ref ProjectSettings.Issues.componentIgnoresFilters, newFilter);

                            ApplyNewIgnoreFilter(newFilter);

                            MaintainerWindow.ShowNotification("Ignore added: " + objectIssue.componentName);
                            CleanerFiltersWindow.Refresh();
                        }
                        else
                        {
                            MaintainerWindow.ShowNotification("Already added to the ignores!");
                        }
                    });
                }
            }


            menu.ShowAsContext();
        }
Exemplo n.º 17
0
        protected virtual void DrawCollectionPages()
        {
            var fromItem = recordsCurrentPage * RecordsPerPage;
            var toItem   = fromItem + Math.Min(RecordsPerPage, filteredRecords.Length - fromItem);

            using (new GUILayout.HorizontalScope(UIHelpers.panelWithBackground))
            {
                GUILayout.Label(fromItem + 1 + " - " + toItem + " from " + filteredRecords.Length /* + " (" + records.Count + " total)"*/);
                GUILayout.FlexibleSpace();
                using (new GUILayout.HorizontalScope())
                {
                    DrawPagesRightHeader();
                }
            }
            UIHelpers.Separator();

            DrawRecords(fromItem, toItem);

            UIHelpers.Separator();

            if (recordsTotalPages <= 1)
            {
                return;
            }

            GUILayout.Space(5);
            using (new GUILayout.HorizontalScope())
            {
                GUILayout.FlexibleSpace();

                GUI.enabled = recordsCurrentPage > 0;
                if (UIHelpers.IconButton(CSIcons.DoubleArrowLeft))
                {
                    window.RemoveNotification();
                    recordsCurrentPage                     = 0;
                    searchSectionScrollPosition            = Vector2.zero;
                    GetState().searchSectionScrollPosition = Vector2.zero;
                }
                if (UIHelpers.IconButton(CSIcons.ArrowLeft))
                {
                    window.RemoveNotification();
                    recordsCurrentPage--;
                    searchSectionScrollPosition            = Vector2.zero;
                    GetState().searchSectionScrollPosition = Vector2.zero;
                }
                GUI.enabled = true;
                GUILayout.Label(recordsCurrentPage + 1 + " of " + recordsTotalPages, UIHelpers.centeredLabel);
                GUI.enabled = recordsCurrentPage < recordsTotalPages - 1;
                if (UIHelpers.IconButton(CSIcons.ArrowRight))
                {
                    window.RemoveNotification();
                    recordsCurrentPage++;
                    searchSectionScrollPosition            = Vector2.zero;
                    GetState().searchSectionScrollPosition = Vector2.zero;
                }
                if (UIHelpers.IconButton(CSIcons.DoubleArrowRight))
                {
                    window.RemoveNotification();
                    recordsCurrentPage                     = recordsTotalPages - 1;
                    searchSectionScrollPosition            = Vector2.zero;
                    GetState().searchSectionScrollPosition = Vector2.zero;
                }
                GUI.enabled = true;

                GUILayout.FlexibleSpace();
            }
        }
Exemplo n.º 18
0
        internal void Draw(MaintainerWindow parentWindow)
        {
            using (UIHelpers.Horizontal())
            {
                /* logo */

                using (UIHelpers.Vertical(UIHelpers.panelWithBackground, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true)))
                {
                    GUILayout.FlexibleSpace();

                    using (UIHelpers.Horizontal())
                    {
                        GUILayout.FlexibleSpace();

                        Texture2D logo = GetLogoTexture(EditorGUIUtility.isProSkin ? LOGO_DARK_NAME : LOGO_LIGHT_NAME);
                        if (logo != null)
                        {
                            Rect logoRect = EditorGUILayout.GetControlRect(GUILayout.Width(logo.width), GUILayout.Height(logo.height));
                            GUI.DrawTexture(logoRect, logo);
                            GUILayout.Space(5);
                        }

                        GUILayout.FlexibleSpace();
                    }

                    GUILayout.FlexibleSpace();
                }

                /* buttons and stuff */

                using (UIHelpers.Vertical(UIHelpers.panelWithBackground, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true)))
                {
                    GUILayout.Space(10);
                    GUILayout.Label("<size=18>Maintainer v.<b>" + Maintainer.VERSION + "</b></size>", UIHelpers.centeredLabel);
                    GUILayout.Space(5);
                    GUILayout.Label("Developed by Dmitriy Yukhanov\n" +
                                    "Logo by Daniele Giardini", UIHelpers.centeredLabel);
                    GUILayout.Space(10);
                    UIHelpers.Separator();
                    GUILayout.Space(5);
                    if (GUILayout.Button("Homepage"))
                    {
                        Application.OpenURL(HOMEPAGE);
                    }
                    GUILayout.Space(5);
                    if (GUILayout.Button("Support contacts"))
                    {
                        Application.OpenURL(SUPPORT_LINK);
                    }
                    GUILayout.Space(5);
                    if (GUILayout.Button("Full changelog (online)"))
                    {
                        Application.OpenURL(CHANGELOG_LINK);
                    }
                    GUILayout.Space(5);

                    //GUILayout.Space(10);
                    //GUILayout.Label("Asset Store links", UIHelpers.centeredLabel);
                    UIHelpers.Separator();
                    GUILayout.Space(5);
                    if (GUILayout.Button(new GUIContent("Plugin at Unity Asset Store")))
                    {
                        Application.OpenURL(UAS_LINK);
                    }
                    GUILayout.Label("It's really important to know your opinion,\n rates & reviews are <b>greatly appreciated!</b>", UIHelpers.centeredLabel);
                    GUILayout.Space(5);
                    if (GUILayout.Button("My profile at Unity Asset Store"))
                    {
                        Application.OpenURL(UAS_PROFILE_LINK);
                    }
                    GUILayout.Label("Check all my plugins!", UIHelpers.centeredLabel);
                }
            }
        }
Exemplo n.º 19
0
        private void DrawHeader()
        {
            using (new GUILayout.HorizontalScope())
            {
                using (new GUILayout.VerticalScope())
                {
                    GUILayout.Label("<size=13>Here you may check any project assets for all project references.</size>", UIHelpers.richWordWrapLabel);

                    if (UIHelpers.ImageButton("Find all assets references",
                                              "Traverses whole project to find where all assets are referenced.", CSIcons.Find))
                    {
                        if (Event.current.control && Event.current.shift)
                        {
                            ReferencesFinder.debugMode = true;
                            AssetsMap.Delete();
                            Event.current.Use();
                        }
                        else
                        {
                            ReferencesFinder.debugMode = false;
                        }
                        EditorApplication.delayCall += StartProjectReferencesScan;
                    }

                    if (ReferencesFinder.GetSelectedAssets().Length == 0)
                    {
                        GUI.enabled = false;
                    }
                    if (UIHelpers.ImageButton("Find selected assets references",
                                              "Adds selected Project View assets to the current search results.", CSIcons.Find))
                    {
                        EditorApplication.delayCall += () => ReferencesFinder.AddSelectedToSelectionAndRun();
                    }
                    GUI.enabled = true;
                }

                GUILayout.Space(30);

                using (new GUILayout.VerticalScope(UIHelpers.panelWithBackground, GUILayout.Width(250)))
                {
                    GUILayout.Space(5);
                    using (new GUILayout.HorizontalScope())
                    {
                        GUILayout.Space(3);
                        if (UIHelpers.ImageButton("Manage Filters... (" + MaintainerSettings.References.pathIgnoresFilters.Length + ")",
                                                  CSIcons.Gear, GUILayout.ExpandWidth(false)))
                        {
                            ReferencesFiltersWindow.Create();
                        }
                        GUILayout.FlexibleSpace();
                        if (UIHelpers.ImageButton(null, "Show some extra info and notes about " + ReferencesFinder.ModuleName + ".", CSIcons.HelpOutline, GUILayout.ExpandWidth(false)))
                        {
                            EditorUtility.DisplayDialog(ReferencesFinder.ModuleName + " Extra Info",
                                                        "Except buttons on this tab, you may use these commands to search for references:\n\n" +
                                                        "Search for asset references from the Project Browser context menu:\n" +
                                                        MaintainerMenu.ProjectBrowserContextReferencesFinderName + "\n\n" +
                                                        "Look for the MonoBehaviour and ScriptableObject references from the Components' or ScriptableObjects' context menus\n" +
                                                        MaintainerMenu.ScriptReferencesContextMenuName + "\n\n" +
                                                        "Or just drag && drop items from Project Browser or Inspector to the list." + "\n\n" +
                                                        "Note #1: you'll see only those references which Maintainer was able to figure out. " +
                                                        "Some kinds of references can't be statically found or not supported yet." + "\n\n" +
                                                        "Note #2: not referenced assets still may be used at runtime or from Editor scripting.", "OK");
                        }

                        GUILayout.Space(3);
                    }

                    MaintainerPersonalSettings.References.showAssetsWithoutReferences = GUILayout.Toggle(
                        MaintainerPersonalSettings.References.showAssetsWithoutReferences,
                        new GUIContent("Add assets without found references", "Check to see all scanned assets in the list even if there was no any references to the asset found in project."), GUILayout.ExpandWidth(false));

                    MaintainerPersonalSettings.References.selectedFindClearsResults = GUILayout.Toggle(
                        MaintainerPersonalSettings.References.selectedFindClearsResults,
                        new GUIContent(@"Clear results on selected assets search", "Check to automatically clear last results on selected assets find both from context menu and main window.\nUncheck to add new results to the last results."), GUILayout.ExpandWidth(false));

                    GUILayout.Space(3);
                }
            }
        }
        private static void DrawSearchSection()
        {
            GUILayout.BeginVertical(UIHelpers.panelWithBackground, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true));
            GUILayout.Space(10);
            if (GUILayout.Button("Find issues!"))
            {
                startSearch = true;
            }
            GUILayout.Space(10);
            if (issues == null || issues.Length == 0)
            {
                GUILayout.Label("No issues");
            }
            else
            {
                int fromIssue = issuesCurrentPage * ISSUES_PER_PAGE;
                int toIssue   = fromIssue + Math.Min(ISSUES_PER_PAGE, issues.Length - fromIssue);

                GUILayout.Label("Issues " + fromIssue + " - " + toIssue + " from " + issues.Length);


                searchSectionScrollPosition = GUILayout.BeginScrollView(searchSectionScrollPosition);
                for (int i = fromIssue; i < toIssue; i++)
                {
                    IssueRecord issue = issues[i];
                    UIHelpers.Separator();
                    GUILayout.BeginVertical();
                    GUILayout.BeginHorizontal();

                    DrawIssueIcon(issue);
                    if (issue.source == IssueSource.Prefab)
                    {
                        DrawPrefabIcon();
                    }
                    GUILayout.Label(issue.GetHeader(), UIHelpers.richLabel, GUILayout.ExpandWidth(false));

                    GUILayout.EndHorizontal();
                    GUILayout.Label(issue.GetBody(), UIHelpers.richLabel);
                    GUILayout.BeginHorizontal(UIHelpers.panelWithBackground);
                    if (GUILayout.Button(new GUIContent("Show", "Selects Game Object with issue in the scene or Project Browser. Opens scene with needed Game Object if necessary and highlights this scene in the Project Browser."), GUILayout.Width(50)))
                    {
                        gotoIssue = issues[i];
                    }

                    if (GUILayout.Button(new GUIContent("Copy", "Copies record text to the clipboard."), GUILayout.Width(50)))
                    {
                        textEditorForClipboard.content = new GUIContent(issue.ToString(true));
                        textEditorForClipboard.SelectAll();
                        textEditorForClipboard.Copy();
                        window.ShowNotification(new GUIContent("Issue record copied to clipboard!"));
                    }
                    GUILayout.EndHorizontal();
                    GUILayout.EndVertical();
                }
                GUILayout.EndScrollView();

                if (issuesTotalPages > 1)
                {
                    GUILayout.Space(5);
                    GUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();

                    GUI.enabled = (issuesCurrentPage > 0);
                    if (GUILayout.Button("<<", GUILayout.Width(50)))
                    {
                        window.RemoveNotification();
                        issuesCurrentPage           = 0;
                        searchSectionScrollPosition = Vector2.zero;
                    }
                    if (GUILayout.Button("<", GUILayout.Width(50)))
                    {
                        window.RemoveNotification();
                        issuesCurrentPage--;
                        searchSectionScrollPosition = Vector2.zero;
                    }
                    GUI.enabled = true;
                    GUILayout.Label((issuesCurrentPage + 1) + " of " + issuesTotalPages, UIHelpers.centeredLabel, GUILayout.Width(100));
                    GUI.enabled = (issuesCurrentPage < issuesTotalPages - 1);
                    if (GUILayout.Button(">", GUILayout.Width(50)))
                    {
                        window.RemoveNotification();
                        issuesCurrentPage++;
                        searchSectionScrollPosition = Vector2.zero;
                    }
                    if (GUILayout.Button(">>", GUILayout.Width(50)))
                    {
                        window.RemoveNotification();
                        issuesCurrentPage           = issuesTotalPages - 1;
                        searchSectionScrollPosition = Vector2.zero;
                    }
                    GUI.enabled = true;

                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();
                }

                GUILayout.Space(5);

                GUILayout.BeginVertical();
                GUILayout.BeginHorizontal();
                if (GUILayout.Button("Copy report to clipboard"))
                {
                    textEditorForClipboard.content = new GUIContent(IssuesFinder.GenerateReport(issues));
                    textEditorForClipboard.SelectAll();
                    textEditorForClipboard.Copy();
                    window.ShowNotification(new GUIContent("Report copied to clipboard!"));
                }
                if (GUILayout.Button("Export report..."))
                {
                    string filePath = EditorUtility.SaveFilePanel("Save Issues Finder report", "", "MaintainerIssuesReport.txt", "txt");
                    if (!String.IsNullOrEmpty(filePath))
                    {
                        StreamWriter sr = File.CreateText(filePath);
                        sr.Write(IssuesFinder.GenerateReport(issues));
                        sr.Close();
                        window.ShowNotification(new GUIContent("Report saved!"));
                    }
                }
                GUILayout.EndHorizontal();
                GUILayout.EndVertical();
            }
            GUILayout.EndVertical();
        }
Exemplo n.º 21
0
        protected override void DrawSearchBody()
        {
            //GUILayout.BeginHorizontal();
            if (GUILayout.Button("1. Find garbage!"))
            {
                startSearch = true;
            }

            if (GUILayout.Button("2. Clean selected items!"))
            {
                startClean = true;
            }
            //GUILayout.EndHorizontal();
            GUILayout.Space(10);

            if (records == null || records.Length == 0)
            {
                GUILayout.Label("No garbage");
            }
            else
            {
                ShowCollectionPages();

                GUILayout.Space(5);

                using (UIHelpers.Horizontal())
                {
                    if (GUILayout.Button("Select all"))
                    {
                        foreach (CleanerRecord record in records.OfType <CleanerRecord>())
                        {
                            record.selected = true;
                        }
                        SearchResultsStorage.Save();
                    }

                    if (GUILayout.Button("Select none"))
                    {
                        foreach (CleanerRecord record in records.OfType <CleanerRecord>())
                        {
                            record.selected = false;
                        }
                        SearchResultsStorage.Save();
                    }

                    if (GUILayout.Button("Clear results"))
                    {
                        records = null;
                        SearchResultsStorage.CleanerSearchResults = null;
                    }
                }

                using (UIHelpers.Horizontal())
                {
                    if (GUILayout.Button("Copy report to clipboard"))
                    {
                        EditorGUIUtility.systemCopyBuffer = ReportsBuilder.GenerateReport(ProjectCleaner.MODULE_NAME, records);
                        MaintainerWindow.ShowNotification("Report copied to clipboard!");
                    }
                    if (GUILayout.Button("Export report..."))
                    {
                        string filePath = EditorUtility.SaveFilePanel("Save " + ProjectCleaner.MODULE_NAME + " report", "", "MaintainerCleanerReport.txt", "txt");
                        if (!string.IsNullOrEmpty(filePath))
                        {
                            StreamWriter sr = File.CreateText(filePath);
                            sr.Write(ReportsBuilder.GenerateReport(ProjectCleaner.MODULE_NAME, records));
                            sr.Close();
                            MaintainerWindow.ShowNotification("Report saved!");
                        }
                    }
                }
            }
        }
Exemplo n.º 22
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);
            }
        }
Exemplo n.º 23
0
        private void DrawMoreButton(AssetRecord assetRecord)
        {
            if (UIHelpers.RecordButton(assetRecord, "Shows menu with additional actions for this record.", CSIcons.More))
            {
                var menu = new GenericMenu();
                if (!string.IsNullOrEmpty(assetRecord.path))
                {
                    menu.AddItem(new GUIContent("Ignore/Full Path"), false, () =>
                    {
                        if (!CSFilterTools.IsValueMatchesAnyFilter(assetRecord.assetDatabasePath, MaintainerSettings.Cleaner.pathIgnoresFilters))
                        {
                            var newFilter = FilterItem.Create(assetRecord.assetDatabasePath, FilterKind.Path);
                            ArrayUtility.Add(ref MaintainerSettings.Cleaner.pathIgnoresFilters, newFilter);

                            MaintainerWindow.ShowNotification("Ignore added: " + assetRecord.assetDatabasePath);
                            CleanerFiltersWindow.Refresh();

                            if (MaintainerSettings.Cleaner.rescanAfterContextIgnore)
                            {
                                StartSearch();
                            }
                        }
                        else
                        {
                            MaintainerWindow.ShowNotification("Already added to the ignores!");
                        }
                    });

                    var dir = Directory.GetParent(assetRecord.assetDatabasePath);
                    if (!CSPathTools.IsAssetsRootPath(dir.FullName))
                    {
                        menu.AddItem(new GUIContent("Ignore/Parent Folder"), false, () =>
                        {
                            var dirPath = CSPathTools.EnforceSlashes(dir.ToString());

                            if (!CSFilterTools.IsValueMatchesAnyFilter(dirPath, MaintainerSettings.Cleaner.pathIgnoresFilters))
                            {
                                var newFilter = FilterItem.Create(dirPath, FilterKind.Directory);
                                ArrayUtility.Add(ref MaintainerSettings.Cleaner.pathIgnoresFilters, newFilter);

                                MaintainerWindow.ShowNotification("Ignore added: " + dirPath);
                                CleanerFiltersWindow.Refresh();

                                if (MaintainerSettings.Cleaner.rescanAfterContextIgnore)
                                {
                                    StartSearch();
                                }
                            }
                            else
                            {
                                MaintainerWindow.ShowNotification("Already added to the ignores!");
                            }
                        });
                    }

                    var extension = Path.GetExtension(assetRecord.path);
                    if (!string.IsNullOrEmpty(extension))
                    {
                        menu.AddItem(new GUIContent("Ignore/\"" + extension + "\" Extension"), false, () =>
                        {
                            if (!CSFilterTools.IsValueMatchesAnyFilterOfKind(extension, MaintainerSettings.Cleaner.pathIgnoresFilters, FilterKind.Extension))
                            {
                                var newFilter = FilterItem.Create(extension, FilterKind.Extension, true);
                                ArrayUtility.Add(ref MaintainerSettings.Cleaner.pathIgnoresFilters, newFilter);

                                MaintainerWindow.ShowNotification("Ignore added: " + extension);
                                CleanerFiltersWindow.Refresh();

                                if (MaintainerSettings.Cleaner.rescanAfterContextIgnore)
                                {
                                    StartSearch();
                                }
                            }
                            else
                            {
                                MaintainerWindow.ShowNotification("Already added to the ignores!");
                            }
                        });
                    }
                }
                menu.ShowAsContext();
            }
        }
Exemplo n.º 24
0
        protected override void DrawRecord(int recordIndex, out bool recordRemoved)
        {
            recordRemoved = false;
            RecordBase record = records[recordIndex];

            UIHelpers.Separator();

            using (UIHelpers.Horizontal())
            {
                DrawSeverityIcon(record);
                if (record.location == RecordLocation.Prefab)
                {
                    UIHelpers.DrawPrefabIcon();
                }
                GUILayout.Label(record.GetHeader(), UIHelpers.richLabel, GUILayout.ExpandWidth(false));
            }

            GUILayout.Label(record.GetBody(), UIHelpers.richLabel);

            using (UIHelpers.Horizontal(UIHelpers.panelWithBackground))
            {
                AddShowButtonIfPossible(record);

                if (GUILayout.Button(new GUIContent("Copy", "Copies record text to the clipboard."), UIHelpers.recordButton))
                {
                    EditorGUIUtility.systemCopyBuffer = record.ToString(true);
                    MaintainerWindow.ShowNotification("Issue record copied to clipboard!");
                }

                if (GUILayout.Button(new GUIContent("Hide", "Hide this issue from the results list.\nUseful when you fixed issue and wish to hide it away."), UIHelpers.recordButton))
                {
                    // ReSharper disable once CoVariantArrayConversion
                    records = CSArrayTools.RemoveAt(records as IssueRecord[], recordIndex);
                    SearchResultsStorage.IssuesSearchResults = (IssueRecord[])records;
                    recordRemoved = true;
                    return;
                }

                //UIHelpers.VerticalSeparator();
                GameObjectIssueRecord objectIssue = record as GameObjectIssueRecord;
                if (objectIssue != null)
                {
                    if (GUILayout.Button("More ...", UIHelpers.recordButton))
                    {
                        GenericMenu menu = new GenericMenu();
                        if (!string.IsNullOrEmpty(objectIssue.path))
                        {
                            menu.AddItem(new GUIContent("Ignore/Add path to ignores"), false, () =>
                            {
                                if (CSArrayTools.AddIfNotExists(ref MaintainerSettings.Issues.pathIgnores, objectIssue.path))
                                {
                                    MaintainerSettings.Save();
                                    MaintainerWindow.ShowNotification("Ignore added: " + objectIssue.path);
                                    IssuesIgnoresWindow.Refresh();
                                }
                                else
                                {
                                    MaintainerWindow.ShowNotification("Such item already added to the ignores!");
                                }
                            });

                            DirectoryInfo dir = Directory.GetParent(objectIssue.path);
                            if (dir.Name != "Assets")
                            {
                                menu.AddItem(new GUIContent("Ignore/Add parent directory to ignores"), false, () =>
                                {
                                    if (CSArrayTools.AddIfNotExists(ref MaintainerSettings.Issues.pathIgnores, dir.ToString()))
                                    {
                                        MaintainerSettings.Save();
                                        MaintainerWindow.ShowNotification("Ignore added: " + dir);
                                        IssuesIgnoresWindow.Refresh();
                                    }
                                    else
                                    {
                                        MaintainerWindow.ShowNotification("Such item already added to the ignores!");
                                    }
                                });
                            }
                        }

                        if (!string.IsNullOrEmpty(objectIssue.component))
                        {
                            menu.AddItem(new GUIContent("Ignore/Add component to ignores"), false, () =>
                            {
                                if (CSArrayTools.AddIfNotExists(ref MaintainerSettings.Issues.componentIgnores, objectIssue.component))
                                {
                                    MaintainerSettings.Save();
                                    MaintainerWindow.ShowNotification("Ignore added: " + objectIssue.component);
                                    IssuesIgnoresWindow.Refresh();
                                }
                                else
                                {
                                    MaintainerWindow.ShowNotification("Such item already added to the ignores!");
                                }
                            });
                        }
                        menu.ShowAsContext();
                    }
                }
            }
        }
Exemplo n.º 25
0
        private static void DrawWhereSection(/*ref Vector2 settingsSectionScrollPosition*/)
        {
            // -----------------------------------------------------------------------------
            // where to look
            // -----------------------------------------------------------------------------

            using (new GUILayout.VerticalScope(/*UIHelpers.panelWithBackground*/))
            {
                using (new GUILayout.HorizontalScope())
                {
                    GUILayout.Space(10);
                    using (new GUILayout.VerticalScope())
                    {
                        GUILayout.Label("<b><size=16>Where</size></b>", UIHelpers.richLabel);
                        UIHelpers.Separator();
                    }
                    GUILayout.Space(10);
                }

                using (new GUILayout.HorizontalScope())
                {
                    GUILayout.Space(10);

                    using (new GUILayout.VerticalScope())
                    {
                        GUILayout.Space(10);

                        if (UIHelpers.ImageButton("Filters (" + ProjectSettings.Issues.GetFiltersCount() + ")", CSIcons.Filter))
                        {
                            IssuesFiltersWindow.Create();
                        }

                        GUILayout.Space(10);

                        using (new GUILayout.HorizontalScope())
                        {
                            ProjectSettings.Issues.lookInScenes = EditorGUILayout.ToggleLeft(new GUIContent("Scenes",
                                                                                                            "Uncheck to exclude all scenes from search or select filtering level:\n\n" +
                                                                                                            "All Scenes: all project scenes with respect to configured filters.\n" +
                                                                                                            "Included Scenes: scenes included via Manage Filters > Scene Includes.\n" +
                                                                                                            "Current Scene: currently opened scene including any additional loaded scenes."),
                                                                                             ProjectSettings.Issues.lookInScenes, GUILayout.Width(70));
                            GUI.enabled = ProjectSettings.Issues.lookInScenes;
                            ProjectSettings.Issues.scenesSelection = (IssuesFinderSettings.ScenesSelection)EditorGUILayout.EnumPopup(ProjectSettings.Issues.scenesSelection);
                            GUI.enabled = true;
                        }

                        ProjectSettings.Issues.lookInAssets          = EditorGUILayout.ToggleLeft(new GUIContent("File assets", "Uncheck to exclude all file assets like prefabs, ScriptableObjects and such from the search. Check readme for additional details."), ProjectSettings.Issues.lookInAssets);
                        ProjectSettings.Issues.lookInProjectSettings = EditorGUILayout.ToggleLeft(new GUIContent("Project Settings", "Uncheck to exclude all file assets like prefabs, ScriptableObjects and such from the search. Check readme for additional details."), ProjectSettings.Issues.lookInProjectSettings);

                        UIHelpers.Separator(5);

                        var canScanGamObjects = ProjectSettings.Issues.lookInScenes || ProjectSettings.Issues.lookInAssets;
                        GUI.enabled = canScanGamObjects;
                        var scanGameObjects = UIHelpers.ToggleFoldout(ref ProjectSettings.Issues.scanGameObjects, ref UserSettings.Issues.scanGameObjectsFoldout, new GUIContent("Game Objects", "Specify if you wish to look for GameObjects issues."), GUILayout.Width(110));
                        GUI.enabled = scanGameObjects && canScanGamObjects;
                        if (UserSettings.Issues.scanGameObjectsFoldout)
                        {
                            UIHelpers.IndentLevel();
                            ProjectSettings.Issues.touchInactiveGameObjects = EditorGUILayout.ToggleLeft(new GUIContent("Inactive Game Objects", "Uncheck to exclude all inactive Game Objects from the search."), ProjectSettings.Issues.touchInactiveGameObjects);
                            ProjectSettings.Issues.touchDisabledComponents  = EditorGUILayout.ToggleLeft(new GUIContent("Disabled Components", "Uncheck to exclude all disabled Components from the search."), ProjectSettings.Issues.touchDisabledComponents);
                            UIHelpers.UnIndentLevel();
                        }

                        GUI.enabled = true;
                    }

                    GUILayout.Space(10);
                }

                GUILayout.Space(10);
            }
        }
Exemplo n.º 26
0
        protected override void RowGUI(RowGUIArgs args)
        {
            CenterRectUsingSingleLineHeight(ref args.rowRect);

            var item     = (ExactReferencesListItem <T>)args.item;
            var lastRect = args.rowRect;

            lastRect.xMin += 4;

            if (item.data == null || item.data.entry == null)
            {
                GUI.Label(lastRect, item.displayName);
                return;
            }

            var  entry = item.data.entry;
            Rect iconRect;

            if (entry.location == Location.NotFound)
            {
                iconRect        = lastRect;
                iconRect.width  = UIHelpers.WarningIconSize;
                iconRect.height = UIHelpers.WarningIconSize;

                GUI.DrawTexture(iconRect, CSEditorIcons.WarnSmallIcon, ScaleMode.ScaleToFit);
                lastRect.xMin += UIHelpers.WarningIconSize + UIHelpers.EyeButtonPadding;
            }
            else if (entry.location == Location.Invisible)
            {
                iconRect        = lastRect;
                iconRect.width  = UIHelpers.WarningIconSize;
                iconRect.height = UIHelpers.WarningIconSize;

                GUI.DrawTexture(iconRect, CSEditorIcons.InfoSmallIcon, ScaleMode.ScaleToFit);
                lastRect.xMin += UIHelpers.WarningIconSize + UIHelpers.EyeButtonPadding;
            }
            else
            {
                iconRect        = lastRect;
                iconRect.width  = UIHelpers.EyeButtonSize;
                iconRect.height = UIHelpers.EyeButtonSize;
                if (UIHelpers.IconButton(iconRect, CSIcons.Show))
                {
                    ShowItem(item);
                }
                lastRect.xMin += UIHelpers.EyeButtonSize + UIHelpers.EyeButtonPadding;
            }

            var boxRect = iconRect;

            boxRect.height = lastRect.height;
            boxRect.xMin   = iconRect.xMax;
            boxRect.xMax   = lastRect.xMax;

            GUI.backgroundColor = entry.location != Location.NotFound ? CSColors.backgroundGreenTint : CSColors.backgroundRedTint;
            GUI.Box(boxRect, GUIContent.none);
            GUI.backgroundColor = Color.white;

            var label = entry.GetLabel();

            DefaultGUI.Label(lastRect, label, args.selected, args.focused);
        }
        private static void DrawSettingsSection()
        {
            MaintainerSettings.Issues.drawMode = true;

            GUILayout.BeginVertical(UIHelpers.panelWithBackground, GUILayout.ExpandHeight(true), GUILayout.Width(300));
            GUILayout.Space(10);
            GUILayout.Label("<size=14><b>Settings</b></size>", UIHelpers.centeredLabel);
            GUILayout.Space(10);

            EditorGUI.BeginChangeCheck();
            GUILayout.BeginVertical(UIHelpers.panelWithBackground);
            GUILayout.Space(5);
            GUILayout.Label("<b>Filtering options:</b>", UIHelpers.richLabel);
            GUILayout.Space(5);
            GUILayout.BeginHorizontal();
            MaintainerSettings.Issues.lookInScenes = EditorGUILayout.ToggleLeft(new GUIContent("Scenes", "Uncheck to exclude all scenes from search or select filtering level:\n\n" +
                                                                                               "All Scenes: all project scenes.\n" +
                                                                                               "Build Scenes: enabled scenes at Build Settings.\n" +
                                                                                               "Current Scene: currently opened scene."), MaintainerSettings.Issues.lookInScenes, GUILayout.Width(70));
            GUI.enabled = MaintainerSettings.Issues.lookInScenes;
            MaintainerSettings.Issues.scenesSelection = (IssuesSettings.ScenesSelection)EditorGUILayout.EnumPopup(MaintainerSettings.Issues.scenesSelection);
            GUI.enabled = true;
            GUILayout.EndHorizontal();
            MaintainerSettings.Issues.lookInAssets             = EditorGUILayout.ToggleLeft(new GUIContent("Prefab assets", "Uncheck to exclude all prefab assets files from the search. Check readme for additional details."), MaintainerSettings.Issues.lookInAssets);
            MaintainerSettings.Issues.touchInactiveGameObjects = EditorGUILayout.ToggleLeft(new GUIContent("Inactive GameObjects", "Uncheck to exclude all inactive Game Objects from the search."), MaintainerSettings.Issues.touchInactiveGameObjects);
            MaintainerSettings.Issues.touchDisabledComponents  = EditorGUILayout.ToggleLeft(new GUIContent("Disabled Components", "Uncheck to exclude all disabled Components from the search."), MaintainerSettings.Issues.touchDisabledComponents);
            GUILayout.Space(2);
            GUILayout.EndVertical();

            GUILayout.BeginVertical(UIHelpers.panelWithBackground, GUILayout.ExpandHeight(true));
            GUILayout.Space(5);
            GUILayout.Label("<b>Search options:</b>", UIHelpers.richLabel);
            GUILayout.Space(5);

            settingsSectionScrollPosition = GUILayout.BeginScrollView(settingsSectionScrollPosition);

            GUI.enabled = UIHelpers.ToggleFoldout(ref MaintainerSettings.Issues.commonToggle, ref MaintainerSettings.Issues.commonFoldout, new GUIContent("Common", "Group of common issues. Uncheck to disable all common issues search."));
            if (MaintainerSettings.Issues.commonFoldout)
            {
                UIHelpers.Indent();
                MaintainerSettings.Issues.MissingComponents   = EditorGUILayout.ToggleLeft(new GUIContent("Missing components", "Search for the missing components on the Game Objects."), MaintainerSettings.Issues.MissingComponents);
                MaintainerSettings.Issues.DuplicateComponents = EditorGUILayout.ToggleLeft(new GUIContent("Duplicate components", "Search for the multiple instances of the same component with same values on the same object."), MaintainerSettings.Issues.DuplicateComponents);
                MaintainerSettings.Issues.MissingReferences   = EditorGUILayout.ToggleLeft(new GUIContent("Missing references", "Search for any missing references in the serialized fields of the components."), MaintainerSettings.Issues.MissingReferences);
                MaintainerSettings.Issues.UndefinedTags       = EditorGUILayout.ToggleLeft(new GUIContent("Objects with undefined tags", "Search for GameObjects without any tag."), MaintainerSettings.Issues.UndefinedTags);
                UIHelpers.Unindent();
            }
            GUI.enabled = true;

            GUI.enabled = UIHelpers.ToggleFoldout(ref MaintainerSettings.Issues.prefabsToggle, ref MaintainerSettings.Issues.prefabsFoldout, new GUIContent("Prefabs-related", "Group of prefabs-related issues. Uncheck to disable all prefabs-related issues search."));
            if (MaintainerSettings.Issues.prefabsFoldout)
            {
                UIHelpers.Indent();
                MaintainerSettings.Issues.MissingPrefabs      = EditorGUILayout.ToggleLeft(new GUIContent("Instances of missing prefabs", "Search for instances of prefabs which were removed from project."), MaintainerSettings.Issues.MissingPrefabs);
                MaintainerSettings.Issues.DisconnectedPrefabs = EditorGUILayout.ToggleLeft(new GUIContent("Instances of disconnected prefabs", "Search for disconnected prefabs instances."), MaintainerSettings.Issues.DisconnectedPrefabs);
                UIHelpers.Unindent();
            }
            GUI.enabled = true;

            GUI.enabled = UIHelpers.ToggleFoldout(ref MaintainerSettings.Issues.junkToggle, ref MaintainerSettings.Issues.junkFoldout, new GUIContent("Unused components", "Group of unused components issues. Uncheck to disable all unused components issues search."));
            if (MaintainerSettings.Issues.junkFoldout)
            {
                UIHelpers.Indent();
                MaintainerSettings.Issues.EmptyMeshColliders = EditorGUILayout.ToggleLeft("MeshColliders without meshes", MaintainerSettings.Issues.EmptyMeshColliders);
                MaintainerSettings.Issues.EmptyMeshFilters   = EditorGUILayout.ToggleLeft("MeshFilters without meshes", MaintainerSettings.Issues.EmptyMeshFilters);
                MaintainerSettings.Issues.EmptyAnimations    = EditorGUILayout.ToggleLeft("Animations without clips", MaintainerSettings.Issues.EmptyAnimations);
                MaintainerSettings.Issues.EmptyRenderers     = EditorGUILayout.ToggleLeft("Renderers without materials", MaintainerSettings.Issues.EmptyRenderers);
                UIHelpers.Unindent();
            }
            GUI.enabled = true;

            GUI.enabled = UIHelpers.ToggleFoldout(ref MaintainerSettings.Issues.neatnessToggle, ref MaintainerSettings.Issues.neatnessFoldout, new GUIContent("Neatness", "Group of neatness issues. Uncheck to disable all neatness issues search."));
            if (MaintainerSettings.Issues.neatnessFoldout)
            {
                UIHelpers.Indent();
                GUILayout.BeginHorizontal();
                MaintainerSettings.Issues.EmptyArrayItems = EditorGUILayout.ToggleLeft(new GUIContent("Empty array items", "Look for any unused items in arrays."), MaintainerSettings.Issues.EmptyArrayItems, GUILayout.Width(122));
                GUI.enabled = MaintainerSettings.Issues.EmptyArrayItems && MaintainerSettings.Issues.neatnessToggle;
                MaintainerSettings.Issues.SkipEmptyArrayItemsOnPrefabs = EditorGUILayout.ToggleLeft(new GUIContent("Skip prefab assets", "Prefab files can be ignored using this toggle."), MaintainerSettings.Issues.SkipEmptyArrayItemsOnPrefabs, GUILayout.Width(125));
                GUI.enabled = MaintainerSettings.Issues.neatnessToggle;
                GUILayout.EndHorizontal();
                MaintainerSettings.Issues.UnnamedLayers = EditorGUILayout.ToggleLeft(new GUIContent("Objects with unnamed layers", "Search for GameObjects with unnamed layers."), MaintainerSettings.Issues.UnnamedLayers);
                UIHelpers.Unindent();
            }
            GUI.enabled = true;
            GUILayout.EndScrollView();
            UIHelpers.Separator();
            GUILayout.Space(5);
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Check all"))
            {
                MaintainerSettings.Issues.EnableAllSearchOptions();
            }

            if (GUILayout.Button("Uncheck all"))
            {
                MaintainerSettings.Issues.EnableAllSearchOptions(false);
            }

            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
            if (GUILayout.Button(new GUIContent("Reset", "Resets all Issues Finder settings to defaults.")))
            {
                MaintainerSettings.Issues.Reset();
            }
            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(MaintainerSettings.Instance);
            }

            GUILayout.EndVertical();

            MaintainerSettings.Issues.drawMode = false;
        }
Exemplo n.º 28
0
        protected override void DrawSettingsBody()
        {
            using (UIHelpers.Vertical(UIHelpers.panelWithBackground))
            {
                GUILayout.Space(5);

                if (GUILayout.Button("Manage Ignores..."))
                {
                    CleanerIgnoresWindow.Create();
                }

                MaintainerSettings.Cleaner.useTrashBin = EditorGUILayout.ToggleLeft(new GUIContent("Use Trash Bin", "All deleted items will be moved to Trash if selected. Otherwise items will be deleted permanently."), MaintainerSettings.Cleaner.useTrashBin);

                GUILayout.Space(5);
            }

            using (UIHelpers.Vertical(UIHelpers.panelWithBackground, GUILayout.ExpandHeight(true)))
            {
                GUILayout.Space(5);
                GUILayout.Label("<b>Search for:</b>", UIHelpers.richLabel);
                GUILayout.Space(5);

                settingsSectionScrollPosition = GUILayout.BeginScrollView(settingsSectionScrollPosition, GUIStyle.none, GUI.skin.verticalScrollbar);

                using (UIHelpers.Horizontal())
                {
                    MaintainerSettings.Cleaner.findEmptyFolders = EditorGUILayout.ToggleLeft(new GUIContent("Empty folders", "Search for all empty folders in project."), MaintainerSettings.Cleaner.findEmptyFolders, GUILayout.Width(100));
                    GUI.enabled = MaintainerSettings.Cleaner.findEmptyFolders;

                    EditorGUI.BeginChangeCheck();
                    MaintainerSettings.Cleaner.findEmptyFoldersAutomatically = EditorGUILayout.ToggleLeft(new GUIContent("Autorun on script reload", "Perform empty folders clean automatically on every scripts reload."), MaintainerSettings.Cleaner.findEmptyFoldersAutomatically);
                    if (EditorGUI.EndChangeCheck())
                    {
                        if (MaintainerSettings.Cleaner.findEmptyFoldersAutomatically)
                        {
                            EditorUtility.DisplayDialog(ProjectCleaner.MODULE_NAME, "In case you're having thousands of folders in your project this may hang Unity for few additional secs on every scripts reload.\n" + ProjectCleaner.DATA_LOSS_WARNING, "Understood");
                        }
                    }
                    GUI.enabled = true;
                }

                MaintainerSettings.Cleaner.findEmptyScenes = EditorGUILayout.ToggleLeft(new GUIContent("Empty scenes", "Search for all empty scenes in project."), MaintainerSettings.Cleaner.findEmptyScenes);

                GUILayout.EndScrollView();
                UIHelpers.Separator();
                GUILayout.Space(5);

                using (UIHelpers.Horizontal())
                {
                    if (GUILayout.Button("Check all"))
                    {
                        MaintainerSettings.Cleaner.SwitchAll(true);
                    }

                    if (GUILayout.Button("Uncheck all"))
                    {
                        MaintainerSettings.Cleaner.SwitchAll(false);
                    }
                }
            }

            if (GUILayout.Button(new GUIContent("Reset", "Resets settings to defaults.")))
            {
                MaintainerSettings.Cleaner.Reset();
            }
        }
Exemplo n.º 29
0
        public void DrawFooter()
        {
            using (new GUILayout.HorizontalScope())
            {
                GUILayout.Space(10);

                if (SearchResultsStorage.ProjectReferencesLastSearched.Length == 0)
                {
                    GUI.enabled = false;
                }

                if (UIHelpers.ImageButton("Refresh", "Restarts references search for the previous results.",
                                          CSIcons.Repeat))
                {
                    if (Event.current.control && Event.current.shift)
                    {
                        ReferencesFinder.debugMode = true;
                        AssetsMap.Delete();
                        Event.current.Use();
                    }
                    else
                    {
                        ReferencesFinder.debugMode = false;
                    }

                    EditorApplication.delayCall += () =>
                    {
                        ProjectScopeReferencesFinder.FindAssetsReferences(SearchResultsStorage.ProjectReferencesLastSearched, null);
                    };
                }

                GUI.enabled = true;

                if (SearchResultsStorage.ProjectReferencesSearchResults.Length == 0)
                {
                    GUI.enabled = false;
                }

                if (UIHelpers.ImageButton("Collapse all", "Collapses all tree items.", CSIcons.Collapse))
                {
                    treePanel.CollapseAll();
                }

                if (UIHelpers.ImageButton("Expand all", "Expands all tree items.", CSIcons.Expand))
                {
                    treePanel.ExpandAll();
                }

                if (UIHelpers.ImageButton("Clear results", "Clears results tree and empties cache.", CSIcons.Clear))
                {
                    SearchResultsStorage.ProjectReferencesSearchResults = null;
                    SearchResultsStorage.ProjectReferencesLastSearched  = null;
                    Refresh(true);
                }

                GUI.enabled = true;

                GUILayout.Space(10);
            }
            GUILayout.Space(10);
        }
Exemplo n.º 30
0
        public void Draw()
        {
            using (new GUILayout.HorizontalScope())
            {
                /* logo */

                using (new GUILayout.VerticalScope(UIHelpers.panelWithBackground, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true)))
                {
                    GUILayout.FlexibleSpace();

                    using (new GUILayout.HorizontalScope())
                    {
                        GUILayout.FlexibleSpace();

                        var logo = CSImages.Logo;
                        if (logo != null)
                        {
                            logo.wrapMode = TextureWrapMode.Clamp;
                            var logoRect = EditorGUILayout.GetControlRect(GUILayout.Width(logo.width), GUILayout.Height(logo.height));
                            GUI.DrawTexture(logoRect, logo);
                            GUILayout.Space(5);
                        }

                        GUILayout.FlexibleSpace();
                    }

                    GUILayout.FlexibleSpace();
                }

                /* buttons and stuff */

                using (new GUILayout.VerticalScope(UIHelpers.panelWithBackground, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true)))
                {
                    GUILayout.Space(10);
                    GUILayout.Label("<size=18>Maintainer v.<b>" + Maintainer.Version + "</b></size>", UIHelpers.centeredLabel);
                    GUILayout.Space(5);
                    GUILayout.Label("Developed by Dmitriy Yukhanov\n" +
                                    "Logo by Daniele Giardini\n" +
                                    "Icons by Google, Austin Andrews, Cody", UIHelpers.centeredLabel);
                    GUILayout.Space(10);
                    UIHelpers.Separator();
                    GUILayout.Space(5);
                    if (UIHelpers.ImageButton("Homepage", CSIcons.Home))
                    {
                        Application.OpenURL(Homepage);
                    }
                    GUILayout.Space(5);
                    if (UIHelpers.ImageButton("Support contacts", CSIcons.Support))
                    {
                        Application.OpenURL(SupportLink);
                    }
                    GUILayout.Space(5);
                    if (UIHelpers.ImageButton("Full changelog (online)", CSIcons.Log))
                    {
                        Application.OpenURL(ChangelogLink);
                    }
                    GUILayout.Space(5);

                    //GUILayout.Space(10);
                    //GUILayout.Label("Asset Store links", UIHelpers.centeredLabel);
                    UIHelpers.Separator();
                    GUILayout.Space(5);
                    if (UIHelpers.ImageButton("Plugin at Unity Asset Store", "Hold CTRL / CMD to open in built-in Asset Store browser.", CSIcons.AssetStore))
                    {
                        if (!Event.current.control)
                        {
                            Application.OpenURL(UasLink);
                        }
                        else
                        {
                            UnityEditorInternal.AssetStore.Open(UasLinkShort);
                        }
                    }
                    GUILayout.Label("It's really important to know your opinion,\n rates & reviews are <b>greatly appreciated!</b>", UIHelpers.centeredLabel);
                    GUILayout.Space(5);
                    if (UIHelpers.ImageButton("My profile at Unity Asset Store", CSIcons.Publisher))
                    {
                        Application.OpenURL(UasProfileLink);
                    }
                    GUILayout.Label("Check all my plugins!", UIHelpers.centeredLabel);

#if UNITY_2018_3_OR_NEWER
                    if (Event.current.isKey && Event.current.type == EventType.KeyDown && Event.current.control && Event.current.keyCode == KeyCode.D)
#else
                    if (Event.current.isKey && Event.current.control && Event.current.keyCode == KeyCode.D)
#endif
                    {
                        showDebug = !showDebug;
                        Event.current.Use();
                    }

                    if (showDebug)
                    {
                        GUILayout.Space(5);
                        UIHelpers.Separator();
                        GUILayout.Space(5);
                        GUILayout.Label("Welcome to secret debug mode =D");
                        if (GUILayout.Button("Remove Assets Map"))
                        {
                            AssetsMap.Delete();
                        }

                        if (GUILayout.Button("Measure Assets Map build time"))
                        {
                            var sw = Stopwatch.StartNew();
                            AssetsMap.CreateNew();
                            sw.Stop();
                            Debug.Log("Asset Map build took " + sw.Elapsed.TotalSeconds.ToString("0.000", CultureInfo.InvariantCulture) + " seconds");
                        }

                        if (GUILayout.Button("Remove Settings and Close"))
                        {
                            window.Close();
                            MaintainerSettings.Delete();
                        }

                        if (GUILayout.Button("Re-save all scenes in project"))
                        {
                            CSSceneTools.ReSaveAllScenes();
                        }
                    }
                }
            }
        }