Beispiel #1
0
        void Search(string searchText, BuildInfo buildReportToDisplay)
        {
            BuildReportTool.AssetList list = GetAssetListToDisplay(buildReportToDisplay);


            BuildReportTool.FileFilterGroup filter = buildReportToDisplay.FileFilters;

            if (BuildReportTool.Options.ShouldUseConfiguredFileFilters())
            {
                filter = _configuredFileFilterGroup;
            }

            List <BuildReportTool.SizePart> searchResults = new List <BuildReportTool.SizePart>();


            BuildReportTool.SizePart[] assetListToSearchFrom = list.GetListToDisplay(filter);

            for (int n = 0; n < assetListToSearchFrom.Length; ++n)
            {
                if (IsANearStringMatch(assetListToSearchFrom[n].Name, searchText))
                {
                    searchResults.Add(assetListToSearchFrom[n]);
                }
            }

            if (searchResults.Count > 0)
            {
                searchResults.Sort((a, b) => GetFuzzyEqualityScore(searchText, a.Name).CompareTo(GetFuzzyEqualityScore(searchText, b.Name)));
            }

            _searchResults = searchResults.ToArray();
        }
Beispiel #2
0
        void DrawAssetList(Rect position, BuildReportTool.AssetList list, BuildReportTool.FileFilterGroup filter, int length)
        {
            if (list != null)
            {
                if (_searchResults != null && _searchResults.Length == 0)
                {
                    DrawCentralMessage(position, "No search results");
                    return;
                }

                BuildReportTool.SizePart[] assetListToUse;

                var hasSearchResults = _searchResults != null;

                if (hasSearchResults && _searchResults.Length > 0)
                {
                    assetListToUse = _searchResults;
                }
                else
                {
                    assetListToUse = list.GetListToDisplay(filter);
                }

                if (assetListToUse != null)
                {
                    if (assetListToUse.Length == 0)
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.Space(10);
                        GUILayout.Label(Labels.NO_FILES_FOR_THIS_CATEGORY_LABEL, BuildReportTool.Window.Settings.INFO_TITLE_STYLE_NAME);
                        GUILayout.EndHorizontal();
                    }
                    else
                    {
                        EditorGUIUtility.SetIconSize(Vector2.one * ICON_DISPLAY_SIZE);
                        bool useAlt = false;

                        int viewOffset = list.GetViewOffsetForDisplayedList(filter);

                        // if somehow view offset was out of bounds of the SizePart[] array
                        // reset it to zero
                        if (viewOffset >= assetListToUse.Length)
                        {
                            list.SetViewOffsetForDisplayedList(filter, 0);
                            viewOffset = 0;
                        }

                        int len = Mathf.Min(viewOffset + length, assetListToUse.Length);



                        GUILayout.BeginHorizontal();


                        // --------------------------------------------------------------------------------------------------------
                        // column: asset path and name
                        GUILayout.BeginVertical();
                        useAlt = false;

                        //GUILayout.Box("", BuildReportTool.Window.Settings.LIST_COLUMN_HEADER_STYLE_NAME, GUILayout.Height(LIST_HEIGHT), GUILayout.Width(position.width));

                        GUILayout.BeginHorizontal();


                        string sortTypeAssetFullPathStyleName = BuildReportTool.Window.Settings.LIST_COLUMN_HEADER_STYLE_NAME;
                        if (!hasSearchResults && list.CurrentSortType == BuildReportTool.AssetList.SortType.AssetFullPath)
                        {
                            if (list.CurrentSortOrder == BuildReportTool.AssetList.SortOrder.Descending)
                            {
                                sortTypeAssetFullPathStyleName = BuildReportTool.Window.Settings.LIST_COLUMN_HEADER_DESC_STYLE_NAME;
                            }
                            else
                            {
                                sortTypeAssetFullPathStyleName = BuildReportTool.Window.Settings.LIST_COLUMN_HEADER_ASC_STYLE_NAME;
                            }
                        }
                        if (GUILayout.Button("Asset Path", sortTypeAssetFullPathStyleName, GUILayout.Height(LIST_HEIGHT)) && !hasSearchResults)
                        {
                            list.ToggleSort(BuildReportTool.AssetList.SortType.AssetFullPath);
                        }


                        string sortTypeAssetFilenameStyleName = BuildReportTool.Window.Settings.LIST_COLUMN_HEADER_STYLE_NAME;
                        if (!hasSearchResults && list.CurrentSortType == BuildReportTool.AssetList.SortType.AssetFilename)
                        {
                            if (list.CurrentSortOrder == BuildReportTool.AssetList.SortOrder.Descending)
                            {
                                sortTypeAssetFilenameStyleName = BuildReportTool.Window.Settings.LIST_COLUMN_HEADER_DESC_STYLE_NAME;
                            }
                            else
                            {
                                sortTypeAssetFilenameStyleName = BuildReportTool.Window.Settings.LIST_COLUMN_HEADER_ASC_STYLE_NAME;
                            }
                        }
                        if (GUILayout.Button("Asset Filename", sortTypeAssetFilenameStyleName, GUILayout.Height(LIST_HEIGHT)) && !hasSearchResults)
                        {
                            list.ToggleSort(BuildReportTool.AssetList.SortType.AssetFilename);
                        }
                        GUILayout.EndHorizontal();


                        // --------------------------------------------------------------------------------------------------------

                        _assetListScrollPos = GUILayout.BeginScrollView(_assetListScrollPos, BuildReportTool.Window.Settings.HIDDEN_SCROLLBAR_STYLE_NAME, BuildReportTool.Window.Settings.HIDDEN_SCROLLBAR_STYLE_NAME);

                        for (int n = viewOffset; n < len; ++n)
                        {
                            BuildReportTool.SizePart b = assetListToUse[n];

                            string styleToUse  = useAlt ? BuildReportTool.Window.Settings.LIST_SMALL_ALT_STYLE_NAME : BuildReportTool.Window.Settings.LIST_SMALL_STYLE_NAME;
                            bool   inSumSelect = list.InSumSelection(b);
                            if (inSumSelect)
                            {
                                styleToUse = BuildReportTool.Window.Settings.LIST_SMALL_SELECTED_NAME;
                            }

                            GUILayout.BeginHorizontal();

                            // checkbox for selecting
                            bool newInSumSelect = GUILayout.Toggle(inSumSelect, "", GUILayout.Width(20));
                            if (inSumSelect != newInSumSelect)
                            {
                                if (newInSumSelect)
                                {
                                    list.AddToSumSelection(b);
                                }
                                else
                                {
                                    list.RemoveFromSumSelection(b);
                                }
                            }


                            // the asset name
                            Texture icon = AssetDatabase.GetCachedIcon(b.Name);

                            string prettyName = string.Empty;

                            prettyName = string.Format(" {0}. <color=#{1}>{2}{3}</color><b>{4}</b>", (n + 1), GetPathColor(inSumSelect), BuildReportTool.Util.GetAssetPath(b.Name), BuildReportTool.Util.GetAssetPathToNameSeparator(b.Name), BuildReportTool.Util.GetAssetFilename(b.Name));



                            GUIStyle styleObjToUse = GUI.skin.GetStyle(styleToUse);
                            Color    temp          = styleObjToUse.normal.textColor;
                            int      origLeft      = styleObjToUse.padding.left;
                            int      origRight     = styleObjToUse.padding.right;

                            styleObjToUse.normal.textColor = styleObjToUse.onNormal.textColor;
                            styleObjToUse.padding.right    = 0;

                            if (icon == null)
                            {
                                //GUILayout.BeginHorizontal(styleObjToUse);
                                GUILayout.Space(15);
                                //GUILayout.EndHorizontal();
                            }

                            styleObjToUse.normal.textColor = temp;
                            styleObjToUse.padding.left     = 2;
                            if (GUILayout.Button(new GUIContent(prettyName, icon), styleObjToUse, GUILayout.Height(LIST_HEIGHT)))
                            {
                                Utility.PingAssetInProject(b.Name);
                            }
                            styleObjToUse.padding.right = origRight;
                            styleObjToUse.padding.left  = origLeft;


                            GUILayout.EndHorizontal();

                            useAlt = !useAlt;
                        }

                        GUILayout.EndScrollView();

                        GUILayout.EndVertical();



                        // --------------------------------------------------------------------------------------------------------
                        // column: raw file size
                        bool pressedRawSizeSortBtn = DrawColumn(viewOffset, len, BuildReportTool.AssetList.SortType.RawSize, (IsShowingUnusedAssets ? "Raw Size" : "Size"), !hasSearchResults, false,
                                                                list, assetListToUse, (b) => { return(b.RawSize); }, ref _assetListScrollPos);


                        bool showScrollbarForImportedSize = IsShowingUnusedAssets;


                        // --------------------------------------------------------------------------------------------------------
                        // column: imported file size

                        bool pressedImpSizeSortBtn = false;

                        if (IsShowingUnusedAssets)
                        {
                            pressedImpSizeSortBtn = DrawColumn(viewOffset, len, BuildReportTool.AssetList.SortType.ImportedSize, "Imported Size   ", !hasSearchResults, showScrollbarForImportedSize,
                                                               list, assetListToUse, (b) => { return(b.ImportedSize); }, ref _assetListScrollPos);
                        }


                        // --------------------------------------------------------------------------------------------------------
                        // column: percentage to total size
                        bool pressedPercentSortBtn = false;

                        if (IsShowingUsedAssets)
                        {
                            pressedPercentSortBtn = DrawColumn(viewOffset, len, BuildReportTool.AssetList.SortType.PercentSize, "Percent   ", !hasSearchResults, true,
                                                               list, assetListToUse, (b) => {
                                string text = b.Percentage + "%";
                                if (b.Percentage < 0)
                                {
                                    text = Labels.NON_APPLICABLE_PERCENTAGE_LABEL;
                                }
                                return(text);
                            }, ref _assetListScrollPos);
                        }

                        // --------------------------------------------------------------------------------------------------------

                        if (!hasSearchResults)
                        {
                            if (pressedRawSizeSortBtn)
                            {
                                list.ToggleSort(BuildReportTool.AssetList.SortType.RawSize);
                            }
                            else if (pressedImpSizeSortBtn)
                            {
                                list.ToggleSort(BuildReportTool.AssetList.SortType.ImportedSize);
                            }
                            else if (pressedPercentSortBtn)
                            {
                                list.ToggleSort(BuildReportTool.AssetList.SortType.PercentSize);
                            }
                        }


                        GUILayout.EndHorizontal();
                    }
                }
            }
        }
Beispiel #3
0
        void DrawAssetList(Rect position, BuildReportTool.AssetList list, BuildReportTool.FileFilterGroup filter, int length)
        {
            if (list != null)
            {
                if (_searchResults != null && _searchResults.Length == 0)
                {
                    DrawCentralMessage(position, "No search results");
                    return;
                }

                BuildReportTool.SizePart[] assetListToUse;

                var hasSearchResults = _searchResults != null;

                if (hasSearchResults && _searchResults.Length > 0)
                {
                    assetListToUse = _searchResults;
                }
                else
                {
                    assetListToUse = list.GetListToDisplay(filter);
                }

                if (assetListToUse != null)
                {
                    if (assetListToUse.Length == 0)
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.Space(10);
                        GUILayout.Label(Labels.NO_FILES_FOR_THIS_CATEGORY_LABEL, BuildReportTool.Window.Settings.INFO_TITLE_STYLE_NAME);
                        GUILayout.EndHorizontal();
                    }
                    else
                    {
                        EditorGUIUtility.SetIconSize(Vector2.one * ICON_DISPLAY_SIZE);
                        bool useAlt = false;

                        int viewOffset = list.GetViewOffsetForDisplayedList(filter);

                        // if somehow view offset was out of bounds of the SizePart[] array
                        // reset it to zero
                        if (viewOffset >= assetListToUse.Length)
                        {
                            list.SetViewOffsetForDisplayedList(filter, 0);
                            viewOffset = 0;
                        }

                        int len = Mathf.Min(viewOffset + length, assetListToUse.Length);



                        GUILayout.BeginHorizontal();


                        // --------------------------------------------------------------------------------------------------------
                        // column: asset path and name
                        GUILayout.BeginVertical();
                        useAlt = false;

                        //GUILayout.Box("", BuildReportTool.Window.Settings.LIST_COLUMN_HEADER_STYLE_NAME, GUILayout.Height(LIST_HEIGHT), GUILayout.Width(position.width));

                        GUILayout.BeginHorizontal();


                        string sortTypeAssetFullPathStyleName = BuildReportTool.Window.Settings.LIST_COLUMN_HEADER_STYLE_NAME;
                        if (!hasSearchResults && list.CurrentSortType == BuildReportTool.AssetList.SortType.AssetFullPath)
                        {
                            if (list.CurrentSortOrder == BuildReportTool.AssetList.SortOrder.Descending)
                            {
                                sortTypeAssetFullPathStyleName = BuildReportTool.Window.Settings.LIST_COLUMN_HEADER_DESC_STYLE_NAME;
                            }
                            else
                            {
                                sortTypeAssetFullPathStyleName = BuildReportTool.Window.Settings.LIST_COLUMN_HEADER_ASC_STYLE_NAME;
                            }
                        }
                        if (GUILayout.Button("Asset Path", sortTypeAssetFullPathStyleName, GUILayout.Height(LIST_HEIGHT)) && !hasSearchResults)
                        {
                            list.ToggleSort(BuildReportTool.AssetList.SortType.AssetFullPath);
                        }


                        string sortTypeAssetFilenameStyleName = BuildReportTool.Window.Settings.LIST_COLUMN_HEADER_STYLE_NAME;
                        if (!hasSearchResults && list.CurrentSortType == BuildReportTool.AssetList.SortType.AssetFilename)
                        {
                            if (list.CurrentSortOrder == BuildReportTool.AssetList.SortOrder.Descending)
                            {
                                sortTypeAssetFilenameStyleName = BuildReportTool.Window.Settings.LIST_COLUMN_HEADER_DESC_STYLE_NAME;
                            }
                            else
                            {
                                sortTypeAssetFilenameStyleName = BuildReportTool.Window.Settings.LIST_COLUMN_HEADER_ASC_STYLE_NAME;
                            }
                        }
                        if (GUILayout.Button("Asset Filename", sortTypeAssetFilenameStyleName, GUILayout.Height(LIST_HEIGHT)) && !hasSearchResults)
                        {
                            list.ToggleSort(BuildReportTool.AssetList.SortType.AssetFilename);
                        }
                        GUILayout.EndHorizontal();


                        // --------------------------------------------------------------------------------------------------------

                        _assetListScrollPos = GUILayout.BeginScrollView(_assetListScrollPos, BuildReportTool.Window.Settings.HIDDEN_SCROLLBAR_STYLE_NAME, BuildReportTool.Window.Settings.HIDDEN_SCROLLBAR_STYLE_NAME);

                        for (int n = viewOffset; n < len; ++n)
                        {
                            BuildReportTool.SizePart b = assetListToUse[n];

                            string styleToUse  = useAlt ? BuildReportTool.Window.Settings.LIST_SMALL_ALT_STYLE_NAME : BuildReportTool.Window.Settings.LIST_SMALL_STYLE_NAME;
                            bool   inSumSelect = list.InSumSelection(b);
                            if (inSumSelect)
                            {
                                styleToUse = BuildReportTool.Window.Settings.LIST_SMALL_SELECTED_NAME;
                            }

                            GUILayout.BeginHorizontal();

                            if (b.Name.StartsWith("Assets/"))
                            {
                                if (GUILayout.Button("Ping", GUILayout.Width(37)))
                                {
                                    Utility.PingAssetInProject(b.Name);
                                }
                            }
                            else
                            {
                                GUILayout.Space(37);
                            }


                            // the asset name
                            Texture icon = AssetDatabase.GetCachedIcon(b.Name);

                            string prettyName = string.Empty;

                            prettyName = string.Format(" {0}. <color=#{1}>{2}{3}</color><b>{4}</b>", (n + 1), GetPathColor(inSumSelect), BuildReportTool.Util.GetAssetPath(b.Name), BuildReportTool.Util.GetAssetPathToNameSeparator(b.Name), BuildReportTool.Util.GetAssetFilename(b.Name));



                            GUIStyle styleObjToUse = GUI.skin.GetStyle(styleToUse);
                            Color    temp          = styleObjToUse.normal.textColor;
                            int      origLeft      = styleObjToUse.padding.left;
                            int      origRight     = styleObjToUse.padding.right;

                            styleObjToUse.normal.textColor = styleObjToUse.onNormal.textColor;
                            styleObjToUse.padding.right    = 0;

                            if (icon == null)
                            {
                                //GUILayout.BeginHorizontal(styleObjToUse);
                                GUILayout.Space(24);
                                //GUILayout.EndHorizontal();
                            }

                            styleObjToUse.normal.textColor = temp;
                            styleObjToUse.padding.left     = 2;
                            if (GUILayout.Button(new GUIContent(prettyName, icon), styleObjToUse, GUILayout.Height(LIST_HEIGHT)))
                            {
                                if (Event.current.control)
                                {
                                    if (!inSumSelect)
                                    {
                                        list.AddToSumSelection(b);
                                        _lastClickedEntryIdx = n;
                                    }
                                    else
                                    {
                                        list.ToggleSumSelection(b);
                                        _lastClickedEntryIdx = -1;
                                    }
                                }
                                else if (Event.current.shift)
                                {
                                    if (_lastClickedEntryIdx != -1)
                                    {
                                        // select all from last clicked to here
                                        if (_lastClickedEntryIdx < n)
                                        {
                                            for (int addToSelectIdx = _lastClickedEntryIdx; addToSelectIdx <= n; ++addToSelectIdx)
                                            {
                                                list.AddToSumSelection(assetListToUse[addToSelectIdx]);
                                            }
                                        }
                                        else if (_lastClickedEntryIdx > n)
                                        {
                                            for (int addToSelectIdx = n; addToSelectIdx <= _lastClickedEntryIdx; ++addToSelectIdx)
                                            {
                                                list.AddToSumSelection(assetListToUse[addToSelectIdx]);
                                            }
                                        }
                                    }
                                    else
                                    {
                                        list.AddToSumSelection(b);
                                    }

                                    _lastClickedEntryIdx = n;
                                }
                                else
                                {
                                    list.ClearSelection();
                                    list.AddToSumSelection(b);
                                    _lastClickedEntryIdx = n;
                                }
                            }
                            styleObjToUse.padding.right = origRight;
                            styleObjToUse.padding.left  = origLeft;


                            GUILayout.EndHorizontal();

                            useAlt = !useAlt;
                        }


                        GUILayout.Space(SCROLLBAR_BOTTOM_PADDING);

                        GUILayout.EndScrollView();

                        GUILayout.EndVertical();



                        bool pressedRawSizeSortBtn = false;
                        bool pressedImpSizeSortBtn = false;

                        bool pressedSizeBeforeBuildSortBtn = false;

                        // --------------------------------------------------------------------------------------------------------
                        // column: raw file size


                        if (IsShowingUsedAssets && (assetListToUse[0].SizeInAssetsFolderBytes != -1))
                        {
                            pressedSizeBeforeBuildSortBtn = DrawColumn(viewOffset, len, BuildReportTool.AssetList.SortType.SizeBeforeBuild, "Size Before Build   ", !hasSearchResults, false,
                                                                       list, assetListToUse, (b) => b.SizeInAssetsFolder, ref _assetListScrollPos);
                        }

                        if (IsShowingUsedAssets && BuildReportTool.Options.ShowImportedSizeForUsedAssets)
                        {
                            pressedRawSizeSortBtn = DrawColumn(viewOffset, len, BuildReportTool.AssetList.SortType.ImportedSizeOrRawSize, "Size In Build", !hasSearchResults, false,
                                                               list, assetListToUse, (b) =>
                            {
                                // assets in the "StreamingAssets" folder do not have an imported size
                                // in those cases, the raw size is the same as the imported size
                                // so just use the raw size
                                if (b.ImportedSize == "N/A")
                                {
                                    return(b.RawSize);
                                }

                                return(b.ImportedSize);
                            }, ref _assetListScrollPos);
                        }

                        if (IsShowingUnusedAssets || (IsShowingUsedAssets && !BuildReportTool.Options.ShowImportedSizeForUsedAssets))
                        {
                            pressedRawSizeSortBtn = DrawColumn(viewOffset, len, BuildReportTool.AssetList.SortType.RawSize, (IsShowingUnusedAssets ? "Raw Size" : "Size In Build"), !hasSearchResults, false,
                                                               list, assetListToUse, (b) => b.RawSize, ref _assetListScrollPos);
                        }


                        bool showScrollbarForImportedSize = IsShowingUnusedAssets;


                        // --------------------------------------------------------------------------------------------------------
                        // column: imported file size


                        if (IsShowingUnusedAssets)
                        {
                            pressedImpSizeSortBtn = DrawColumn(viewOffset, len, BuildReportTool.AssetList.SortType.ImportedSize, "Imported Size   ", !hasSearchResults, showScrollbarForImportedSize,
                                                               list, assetListToUse, (b) => b.ImportedSize, ref _assetListScrollPos);
                        }


                        // --------------------------------------------------------------------------------------------------------
                        // column: percentage to total size

                        bool pressedPercentSortBtn = false;

                        if (IsShowingUsedAssets)
                        {
                            pressedPercentSortBtn = DrawColumn(viewOffset, len, BuildReportTool.AssetList.SortType.PercentSize, "Percent   ", !hasSearchResults, true,
                                                               list, assetListToUse, (b) => {
                                string text = b.Percentage + "%";
                                if (b.Percentage < 0)
                                {
                                    text = Labels.NON_APPLICABLE_PERCENTAGE_LABEL;
                                }
                                return(text);
                            }, ref _assetListScrollPos);
                        }

                        // --------------------------------------------------------------------------------------------------------

                        if (!hasSearchResults)
                        {
                            if (pressedRawSizeSortBtn)
                            {
                                var sortType = BuildReportTool.AssetList.SortType.RawSize;
                                if (IsShowingUsedAssets && BuildReportTool.Options.ShowImportedSizeForUsedAssets)
                                {
                                    sortType = BuildReportTool.AssetList.SortType.ImportedSizeOrRawSize;
                                }
                                list.ToggleSort(sortType);
                            }
                            else if (pressedSizeBeforeBuildSortBtn)
                            {
                                list.ToggleSort(BuildReportTool.AssetList.SortType.SizeBeforeBuild);
                            }
                            else if (pressedImpSizeSortBtn)
                            {
                                list.ToggleSort(BuildReportTool.AssetList.SortType.ImportedSize);
                            }
                            else if (pressedPercentSortBtn)
                            {
                                list.ToggleSort(BuildReportTool.AssetList.SortType.PercentSize);
                            }
                        }


                        GUILayout.EndHorizontal();
                    }
                }
            }
        }
Beispiel #4
0
        void DrawTopBar(Rect position, BuildInfo buildReportToDisplay, BuildReportTool.FileFilterGroup fileFilterGroupToUse)
        {
            BuildReportTool.AssetList assetListUsed = GetAssetListToDisplay(buildReportToDisplay);

            if (assetListUsed == null)
            {
                return;
            }


            Texture2D prevArrow = GUI.skin.GetStyle(BuildReportTool.Window.Settings.BIG_LEFT_ARROW_ICON_STYLE_NAME).normal.background;
            Texture2D nextArrow = GUI.skin.GetStyle(BuildReportTool.Window.Settings.BIG_RIGHT_ARROW_ICON_STYLE_NAME).normal.background;


            GUILayout.BeginHorizontal(GUILayout.Height(11));

            GUILayout.Label(" ", BuildReportTool.Window.Settings.TOP_BAR_BG_STYLE_NAME);

            // ------------------------------------------------------------------------------------------------------
            // File Filters

            fileFilterGroupToUse.Draw(assetListUsed, position.width - 100);

            // ------------------------------------------------------------------------------------------------------

            GUILayout.Space(20);

            // ------------------------------------------------------------------------------------------------------
            // Unused Assets Batch

            if (IsShowingUnusedAssets)
            {
                int batchNumber = buildReportToDisplay.UnusedAssetsBatchNum + 1;

                if (GUILayout.Button(prevArrow, BuildReportTool.Window.Settings.TOP_BAR_BTN_STYLE_NAME) && (batchNumber - 1 >= 1))
                {
                    // move to previous batch
                    BuildReportTool.ReportGenerator.MoveUnusedAssetsBatchToPrev(buildReportToDisplay, fileFilterGroupToUse);
                }

                string batchLabel = "Batch " + batchNumber;
                GUILayout.Label(batchLabel, BuildReportTool.Window.Settings.TOP_BAR_LABEL_STYLE_NAME);

                if (GUILayout.Button(nextArrow, BuildReportTool.Window.Settings.TOP_BAR_BTN_STYLE_NAME))
                {
                    // move to next batch
                    // (possible to have no new batch anymore. if so, it will just fail silently)
                    BuildReportTool.ReportGenerator.MoveUnusedAssetsBatchToNext(buildReportToDisplay, fileFilterGroupToUse);
                }
            }

            // ------------------------------------------------------------------------------------------------------

            // ------------------------------------------------------------------------------------------------------
            // Paginate Buttons

            BuildReportTool.SizePart[] assetListToUse = assetListUsed.GetListToDisplay(fileFilterGroupToUse);

            int assetListLength = 0;

            if (assetListToUse != null)
            {
                assetListLength = assetListToUse.Length;
            }

            int viewOffset = assetListUsed.GetViewOffsetForDisplayedList(fileFilterGroupToUse);

            int len = Mathf.Min(viewOffset + BuildReportTool.Options.AssetListPaginationLength, assetListLength);
            int offsetNonZeroBased = viewOffset + (len > 0 ? 1 : 0);

            string NUM_STR = "D" + assetListLength.ToString().Length;


            if (GUILayout.Button(prevArrow, BuildReportTool.Window.Settings.TOP_BAR_BTN_STYLE_NAME) && (viewOffset - BuildReportTool.Options.AssetListPaginationLength >= 0))
            {
                assetListUsed.SetViewOffsetForDisplayedList(fileFilterGroupToUse, viewOffset - BuildReportTool.Options.AssetListPaginationLength);
                _assetListScrollPos.y = 0;
            }

            string paginateLabel = "Page " + offsetNonZeroBased.ToString(NUM_STR) + " - " + len.ToString(NUM_STR) + " of " + assetListLength.ToString(NUM_STR);

            GUILayout.Label(paginateLabel, BuildReportTool.Window.Settings.TOP_BAR_LABEL_STYLE_NAME);

            if (GUILayout.Button(nextArrow, BuildReportTool.Window.Settings.TOP_BAR_BTN_STYLE_NAME) && (viewOffset + BuildReportTool.Options.AssetListPaginationLength < assetListLength))
            {
                assetListUsed.SetViewOffsetForDisplayedList(fileFilterGroupToUse, viewOffset + BuildReportTool.Options.AssetListPaginationLength);
                _assetListScrollPos.y = 0;
            }

            // ------------------------------------------------------------------------------------------------------


            GUILayout.FlexibleSpace();

            _searchTextInput = GUILayout.TextField(_searchTextInput, "TextField-Search", GUILayout.MinWidth(200));
            if (GUILayout.Button(string.Empty, "TextField-Search-ClearButton"))
            {
                ClearSearch();
            }

            // ------------------------------------------------------------------------------------------------------
            // Recalculate Imported sizes
            // (makes sense only for unused assets)

            if (_currentListDisplayed != ListToDisplay.UsedAssets && GUILayout.Button(Labels.RECALC_IMPORTED_SIZES, BuildReportTool.Window.Settings.TOP_BAR_BTN_STYLE_NAME))
            {
                assetListUsed.PopulateImportedSizes();
            }

            // ------------------------------------------------------------------------------------------------------



            // ------------------------------------------------------------------------------------------------------
            // Selection buttons

            if (GUILayout.Button(Labels.SELECT_ALL_LABEL, BuildReportTool.Window.Settings.TOP_BAR_BTN_STYLE_NAME))
            {
                assetListUsed.AddAllDisplayedToSumSelection(fileFilterGroupToUse);
            }
            if (GUILayout.Button(Labels.SELECT_NONE_LABEL, BuildReportTool.Window.Settings.TOP_BAR_BTN_STYLE_NAME))
            {
                assetListUsed.ClearSelection();
            }

            // ------------------------------------------------------------------------------------------------------



            // ------------------------------------------------------------------------------------------------------
            // Delete buttons

            if (ShouldShowDeleteButtons(buildReportToDisplay))
            {
                GUI.backgroundColor = Color.red;
                const string delSelectedLabel = "Delete selected";
                if (GUILayout.Button(delSelectedLabel, BuildReportTool.Window.Settings.TOP_BAR_BTN_STYLE_NAME))
                {
                    InitiateDeleteSelectedUsed(buildReportToDisplay);
                }

                const string deleteAllLabel = "Delete all";
                if (GUILayout.Button(deleteAllLabel, BuildReportTool.Window.Settings.TOP_BAR_BTN_STYLE_NAME))
                {
                    InitiateDeleteAllUnused(buildReportToDisplay);
                }

                GUI.backgroundColor = Color.white;
            }

            // ------------------------------------------------------------------------------------------------------

            GUILayout.EndHorizontal();


            GUILayout.Space(5);
        }
        void Search(string searchText, SearchType searchType, bool searchFilenameOnly, bool caseSensitive, BuildInfo buildReportToDisplay)
        {
            if (string.IsNullOrEmpty(searchText))
            {
                _searchResults = null;
                return;
            }

            BuildReportTool.AssetList list = GetAssetListToDisplay(buildReportToDisplay);


            BuildReportTool.FileFilterGroup filter = buildReportToDisplay.FileFilters;

            if (BuildReportTool.Options.ShouldUseConfiguredFileFilters())
            {
                filter = _configuredFileFilterGroup;
            }

            List <BuildReportTool.SizePart> searchResults = new List <BuildReportTool.SizePart>();


            BuildReportTool.SizePart[] assetListToSearchFrom = list.GetListToDisplay(filter);

            var options = caseSensitive ? System.Text.RegularExpressions.RegexOptions.None : System.Text.RegularExpressions.RegexOptions.IgnoreCase;

            for (int n = 0; n < assetListToSearchFrom.Length; ++n)
            {
                string input;
                if (searchFilenameOnly)
                {
                    input = Path.GetFileName(assetListToSearchFrom[n].Name);
                }
                else
                {
                    input = assetListToSearchFrom[n].Name;
                }

                bool assetIsMatch;
                switch (searchType)
                {
                case SearchType.Regex:
                    try
                    {
                        assetIsMatch = System.Text.RegularExpressions.Regex.IsMatch(input, searchText, options);
                    }
                    catch (ArgumentException)
                    {
                        assetIsMatch = false;
                    }
                    break;

                case SearchType.Fuzzy:
                    assetIsMatch = IsANearStringMatch(input, searchText);
                    break;

                default:
                    // default is SearchType.Basic
                    assetIsMatch = System.Text.RegularExpressions.Regex.IsMatch(input, BuildReportTool.Util.WildCardToRegex(searchText), options);
                    break;
                }

                if (assetIsMatch)
                {
                    searchResults.Add(assetListToSearchFrom[n]);
                }
            }

            if (searchResults.Count > 0)
            {
                searchResults.Sort((a, b) =>
                                   GetFuzzyEqualityScore(searchText, a.Name).CompareTo(GetFuzzyEqualityScore(searchText, b.Name)));
            }

            _searchResults = searchResults.ToArray();
        }