Beispiel #1
0
    public static void DrawThumbnailEndUsersTooltip(Rect position, string assetPath, GUIContent label,
                                                    List <GUIContent> endUsers, Rect assetRect)
    {
        var thumbnailImage = BRT_BuildReportWindow.GetAssetPreview(assetPath);

        if (thumbnailImage != null)
        {
            var usedBySpacing = 5;

            var thumbnailSize = BRT_BuildReportWindow.GetThumbnailSize();

            // compute end users height and width
            // then create a tooltip size that encompasses both thumbnail and end users list

            Vector2 endUsersSize = BRT_BuildReportWindow.GetEndUsersListSize(label, endUsers);
            endUsersSize.y += usedBySpacing;

            Vector2 tooltipSize = new Vector2(Mathf.Max(thumbnailSize.x, endUsersSize.x),
                                              thumbnailSize.y + endUsersSize.y);

            var tooltipRect = BRT_BuildReportWindow.DrawTooltip(position, assetRect,
                                                                tooltipSize.x, tooltipSize.y);

            // --------
            // now draw the contents

            BRT_BuildReportWindow.DrawThumbnail(tooltipRect.x, tooltipRect.y, thumbnailSize, thumbnailImage);

            var endUsersPos = tooltipRect.position;
            endUsersPos.y += thumbnailSize.y + usedBySpacing;
            BRT_BuildReportWindow.DrawEndUsersList(endUsersPos, label, endUsers);
        }
    }
Beispiel #2
0
    public static void DrawThumbnailTooltip(Rect position, string assetPath, Rect assetRect)
    {
        var thumbnailImage = BRT_BuildReportWindow.GetAssetPreview(assetPath);

        if (thumbnailImage != null)
        {
            var thumbnailSize = BRT_BuildReportWindow.GetThumbnailSize();

            var tooltipRect = BRT_BuildReportWindow.DrawTooltip(position, assetRect,
                                                                thumbnailSize.x, thumbnailSize.y);

            DrawThumbnail(tooltipRect.x, tooltipRect.y, thumbnailSize, thumbnailImage);
        }
    }
Beispiel #3
0
        void DrawAssetList(BuildReportTool.AssetList assetList, bool usedAssets, BuildInfo buildReportToDisplay,
                           AssetDependencies assetDependencies)
        {
            if (assetList == null || assetList.TopLargest == null)
            {
                //Debug.LogError("no top ten largest");
                return;
            }

            BuildReportTool.SizePart[] assetsToShow = assetList.TopLargest;

            if (assetsToShow == null)
            {
                //Debug.LogError("no top ten largest");
                return;
            }

            bool useAlt = true;

            var newEntryHoveredIdx = -1;

            BuildReportTool.SizePart newEntryHovered = null;
            Rect newEntryHoveredRect = new Rect();
            Rect iconRect            = new Rect();
            var  hoveringOverIcon    = false;

            //var hoveringOverLabel = false;

            GUILayout.BeginHorizontal();

            // 1st column: name
            GUILayout.BeginVertical();
            for (int n = 0; n < assetsToShow.Length; ++n)
            {
                BuildReportTool.SizePart b = assetsToShow[n];

                string styleToUse = useAlt
                                                            ? BuildReportTool.Window.Settings.LIST_NORMAL_ALT_STYLE_NAME
                                                            : BuildReportTool.Window.Settings.LIST_NORMAL_STYLE_NAME;
                string iconStyleToUse = useAlt
                                                                ? BuildReportTool.Window.Settings.LIST_ICON_ALT_STYLE_NAME
                                                                : BuildReportTool.Window.Settings.LIST_ICON_STYLE_NAME;

                Texture icon = AssetDatabase.GetCachedIcon(b.Name);

                GUILayout.BeginHorizontal();
                if (icon == null)
                {
                    // no icon, just add space so it aligns with the other entries
                    GUILayout.Label(string.Empty, iconStyleToUse, GUILayout.Width(28), GUILayout.Height(30));
                }
                else
                {
                    GUILayout.Button(icon, iconStyleToUse, GUILayout.Width(28), GUILayout.Height(30));
                }

                if (Event.current.type == EventType.Repaint)
                {
                    iconRect = GUILayoutUtility.GetLastRect();

                    // if mouse is hovering over asset entry's icon (not the label)
                    // draw a border on the asset icon
                    if (iconRect.Contains(Event.current.mousePosition))
                    {
                        hoveringOverIcon    = true;
                        newEntryHoveredIdx  = n;
                        newEntryHovered     = b;
                        newEntryHoveredRect = iconRect;

                        GUI.Box(iconRect, icon, "IconHovered");
                    }
                }

                string prettyName = string.Format(" {0}. {1}", (n + 1).ToString(), BuildReportTool.Util.GetAssetFilename(b.Name));
                if (GUILayout.Button(prettyName, styleToUse, GUILayout.MinWidth(100), GUILayout.MaxWidth(400),
                                     GUILayout.Height(30)))
                {
                    Utility.PingAssetInProject(b.Name);
                }

                if (newEntryHoveredIdx == -1 && Event.current.type == EventType.Repaint)
                {
                    var labelRect = GUILayoutUtility.GetLastRect();

                    // if mouse is hovering over asset entry's label
                    // draw a border on the asset icon
                    if (labelRect.Contains(Event.current.mousePosition))
                    {
                        //hoveringOverLabel = true;
                        newEntryHoveredIdx  = n;
                        newEntryHovered     = b;
                        newEntryHoveredRect = labelRect;

                        GUI.Box(iconRect, icon, "IconHovered");
                    }
                }

                GUILayout.EndHorizontal();

                useAlt = !useAlt;
            }

            GUILayout.EndVertical();


            if (Event.current.type == EventType.Repaint)
            {
                if (usedAssets)
                {
                    _assetUsedEntryHoveredIdx = newEntryHoveredIdx;
                }
                else
                {
                    _assetUnusedEntryHoveredIdx = newEntryHoveredIdx;
                }

                if (newEntryHoveredIdx != -1)
                {
                    string hoveredAssetPath = newEntryHovered != null ? newEntryHovered.Name : null;

                    // ----------------
                    // update what is considered the hovered asset, for use later on
                    // when the tooltip will be drawn
                    BRT_BuildReportWindow.UpdateHoveredAsset(hoveredAssetPath, newEntryHoveredRect,
                                                             usedAssets, buildReportToDisplay, assetDependencies);

                    // ----------------
                    // if mouse is hovering over the correct area, we signify that
                    // the tooltip thumbnail should be drawn
                    if (BuildReportTool.Options.ShowTooltipThumbnail &&
                        (BuildReportTool.Options.ShowThumbnailOnHoverLabelToo || hoveringOverIcon) &&
                        BRT_BuildReportWindow.GetAssetPreview(hoveredAssetPath) != null)
                    {
                        _shouldShowThumbnailOnHoveredAsset = true;
                    }
                    else
                    {
                        _shouldShowThumbnailOnHoveredAsset = false;
                    }
                }
            }

            // 2nd column: size

            var useRawSize = (usedAssets && !BuildReportTool.Options.ShowImportedSizeForUsedAssets) || !usedAssets;

            useAlt = true;
            GUILayout.BeginVertical();
            for (int n = 0; n < assetsToShow.Length; ++n)
            {
                BuildReportTool.SizePart b = assetsToShow[n];

                string styleToUse = useAlt
                                                            ? BuildReportTool.Window.Settings.LIST_NORMAL_ALT_STYLE_NAME
                                                            : BuildReportTool.Window.Settings.LIST_NORMAL_STYLE_NAME;

                GUILayout.Label(useRawSize ? b.RawSize : b.ImportedSize, styleToUse, GUILayout.MaxWidth(100),
                                GUILayout.Height(30));

                useAlt = !useAlt;
            }

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