BRT_BuildReportWindow.DrawAssetList C# (CSharp) Method

DrawAssetList() private method

private DrawAssetList ( BuildReportTool list, BuildReportTool filter, int length ) : void
list BuildReportTool
filter BuildReportTool
length int
return void
    void DrawAssetList(BuildReportTool.AssetList list, BuildReportTool.FileFilterGroup filter, int length)
    {
        GUILayout.BeginHorizontal();
            GUILayout.Label(ASSET_SIZE_BREAKDOWN_MSG_PRE_BOLD, INFO_SUBTITLE_STYLE_NAME);
            GUILayout.Label(ASSET_SIZE_BREAKDOWN_MSG_BOLD, INFO_SUBTITLE_BOLD_STYLE_NAME);
            GUILayout.Label(ASSET_SIZE_BREAKDOWN_MSG_POST_BOLD, INFO_SUBTITLE_STYLE_NAME);
            GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();

        if (list != null)
        {
            BuildReportTool.SizePart[] assetListToUse = list.GetListToDisplay(filter);

            if (assetListToUse != null)
            {
                if (assetListToUse.Length == 0)
                {
                    GUILayout.Label(NO_FILES_FOR_THIS_CATEGORY, INFO_TITLE_STYLE_NAME);
                }
                else
                {
                    const int LIST_HEIGHT = 20;
                    const int ICON_DISPLAY_SIZE = 15;
                    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();

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

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

                            GUILayout.BeginHorizontal();
                                bool newInSumSelect = GUILayout.Toggle(inSumSelect, "");
                                if (inSumSelect != newInSumSelect)
                                {
                                    if (newInSumSelect)
                                    {
                                        list.AddToSumSelection(b);
                                    }
                                    else
                                    {
                                        list.RemoveFromSumSelection(b);
                                    }
                                }

                                Texture icon = AssetDatabase.GetCachedIcon(b.Name);
                                if (GUILayout.Button(new GUIContent((n+1) + ". " + b.Name, icon), styleToUse, GUILayout.Height(LIST_HEIGHT)))
                                {
                                    PingAssetInProject(b.Name);
                                }
                            GUILayout.EndHorizontal();

                            useAlt = !useAlt;
                        }
                    GUILayout.EndVertical();

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

                            string styleToUse = useAlt ? LIST_SMALL_ALT_STYLE_NAME : LIST_SMALL_STYLE_NAME;
                            if (list.InSumSelection(b))
                            {
                                styleToUse = LIST_SMALL_SELECTED_NAME;
                            }

                            GUILayout.Label(b.Size, styleToUse, GUILayout.MinWidth(50), GUILayout.Height(LIST_HEIGHT));
                            useAlt = !useAlt;
                        }
                    GUILayout.EndVertical();

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

                            string styleToUse = useAlt ? LIST_SMALL_ALT_STYLE_NAME : LIST_SMALL_STYLE_NAME;
                            if (list.InSumSelection(b))
                            {
                                styleToUse = LIST_SMALL_SELECTED_NAME;
                            }

                            string text = b.Percentage + "%";
                            if (b.Percentage < 0)
                            {
                                text = NON_APPLICABLE_PERCENTAGE;
                            }

                            GUILayout.Label(text, styleToUse, GUILayout.MinWidth(30), GUILayout.Height(LIST_HEIGHT));
                            useAlt = !useAlt;
                        }
                    GUILayout.EndVertical();
                    GUILayout.EndHorizontal();
                }
            }
        }
    }