public override void DrawGUI(Rect position, BuildInfo buildReportToDisplay) { GUILayout.Space(2); // top padding for scrollbar _scrollPos = GUILayout.BeginScrollView(_scrollPos); GUILayout.BeginHorizontal(); GUILayout.Space(10); // extra left padding GUILayout.BeginVertical(); GUILayout.Space(10); // top padding // report title GUILayout.Label(buildReportToDisplay.SuitableTitle, BuildReportTool.Window.Settings.MAIN_TITLE_STYLE_NAME); GUILayout.Space(10); // two-column layout GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.BeginVertical(GUILayout.MaxWidth(350)); GUILayout.Label(Labels.TIME_OF_BUILD_LABEL, BuildReportTool.Window.Settings.INFO_TITLE_STYLE_NAME); GUILayout.Label(buildReportToDisplay.GetTimeReadable(), BuildReportTool.Window.Settings.INFO_SUBTITLE_STYLE_NAME); GUILayout.Label("Report generation took:", BuildReportTool.Window.Settings.INFO_TITLE_STYLE_NAME); GUILayout.Label(buildReportToDisplay.ReportGenerationTime.ToString(), BuildReportTool.Window.Settings.INFO_SUBTITLE_STYLE_NAME); if (!string.IsNullOrEmpty(buildReportToDisplay.TotalBuildSize) && !string.IsNullOrEmpty(buildReportToDisplay.BuildFilePath)) { GUILayout.BeginVertical(); GUILayout.Label(Labels.BUILD_TOTAL_SIZE_LABEL, BuildReportTool.Window.Settings.INFO_TITLE_STYLE_NAME); GUILayout.Label(BuildReportTool.Util.GetBuildSizePathDescription(buildReportToDisplay), BuildReportTool.Window.Settings.TINY_HELP_STYLE_NAME); GUILayout.Label(buildReportToDisplay.TotalBuildSize, BuildReportTool.Window.Settings.BIG_NUMBER_STYLE_NAME); GUILayout.EndVertical(); } GUILayout.Space(20); string emphasisColor = "black"; if (EditorGUIUtility.isProSkin) { emphasisColor = "white"; } GUILayout.Label("<color=" + emphasisColor + "><size=20><b>" + buildReportToDisplay.BuildSizes[1].Name + "</b></size></color> are the largest,\ntaking up <color=" + emphasisColor + "><size=20><b>" + buildReportToDisplay.BuildSizes[1].Percentage + "%</b></size></color> of the build" + (buildReportToDisplay.HasStreamingAssets ? "\n<size=12>(not counting streaming assets)</size>" : ""), BuildReportTool.Window.Settings.INFO_TEXT_STYLE_NAME); GUILayout.Space(20); GUILayout.EndVertical(); GUILayout.BeginVertical(GUILayout.MaxWidth(350)); GUILayout.Label("Made for:", BuildReportTool.Window.Settings.INFO_TITLE_STYLE_NAME); GUILayout.Label(buildReportToDisplay.BuildType, BuildReportTool.Window.Settings.INFO_SUBTITLE_STYLE_NAME); GUILayout.Label("Built in:", BuildReportTool.Window.Settings.INFO_TITLE_STYLE_NAME); GUILayout.Label(buildReportToDisplay.UnityVersionDisplayed, BuildReportTool.Window.Settings.INFO_SUBTITLE_STYLE_NAME); GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); var numberOfTopUsed = buildReportToDisplay.HasUsedAssets ? buildReportToDisplay.UsedAssets.NumberOfTopLargest : 0; var numberOfTopUnused = buildReportToDisplay.HasUnusedAssets ? buildReportToDisplay.UnusedAssets.NumberOfTopLargest : 0; var canShowTopUsed = numberOfTopUsed > 0; var canShowTopUnused = numberOfTopUnused > 0; if (canShowTopUsed) { GUILayout.BeginVertical(); GUILayout.Label(string.Format("Top {0} largest in build:", numberOfTopUsed), BuildReportTool.Window.Settings.INFO_TITLE_STYLE_NAME); DrawAssetList(buildReportToDisplay.UsedAssets, true); GUILayout.EndVertical(); } if (canShowTopUsed && canShowTopUnused) { GUILayout.Space(50); } if (canShowTopUnused) { GUILayout.BeginVertical(); GUILayout.Label(string.Format("Top {0} largest not in build:", numberOfTopUnused), BuildReportTool.Window.Settings.INFO_TITLE_STYLE_NAME); DrawAssetList(buildReportToDisplay.UnusedAssets, false); GUILayout.EndVertical(); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.Space(20); GUILayout.EndVertical(); GUILayout.Space(20); // extra right padding GUILayout.EndHorizontal(); GUILayout.EndScrollView(); }
public override void DrawGUI(Rect position, BuildInfo buildReportToDisplay, AssetDependencies assetDependencies, TextureData textureData, UnityBuildReport unityBuildReport, out bool requestRepaint ) { if (buildReportToDisplay == null) { requestRepaint = false; return; } GUILayout.Space(2); // top padding for scrollbar _scrollPos = GUILayout.BeginScrollView(_scrollPos); GUILayout.BeginHorizontal(); GUILayout.Space(10); // extra left padding GUILayout.BeginVertical(); GUILayout.Space(10); // top padding // report title GUILayout.Label(buildReportToDisplay.SuitableTitle, BuildReportTool.Window.Settings.MAIN_TITLE_STYLE_NAME); GUILayout.Space(10); // two-column layout GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); // 1st column GUILayout.BeginVertical(GUILayout.MaxWidth(350)); GUILayout.Label(Labels.TIME_OF_BUILD_LABEL, BuildReportTool.Window.Settings.INFO_TITLE_STYLE_NAME); GUILayout.Label(buildReportToDisplay.GetTimeReadable(), BuildReportTool.Window.Settings.INFO_SUBTITLE_STYLE_NAME); GUILayout.Label("Project building took:", BuildReportTool.Window.Settings.INFO_TITLE_STYLE_NAME); GUILayout.Label("How long the project building took. This is the time between OnPreprocessBuild and OnPostprocessBuild.", BuildReportTool.Window.Settings.TINY_HELP_STYLE_NAME); GUILayout.Label(buildReportToDisplay.BuildDurationTime.ToString(), BuildReportTool.Window.Settings.INFO_SUBTITLE_STYLE_NAME); GUILayout.Label("Report generation took:", BuildReportTool.Window.Settings.INFO_TITLE_STYLE_NAME); GUILayout.Label("How long the Build Report Generation took.", BuildReportTool.Window.Settings.TINY_HELP_STYLE_NAME); GUILayout.Label(buildReportToDisplay.ReportGenerationTime.ToString(), BuildReportTool.Window.Settings.INFO_SUBTITLE_STYLE_NAME); if (!string.IsNullOrEmpty(buildReportToDisplay.TotalBuildSize) && !string.IsNullOrEmpty(buildReportToDisplay.BuildFilePath)) { GUILayout.BeginVertical(); GUILayout.Label(Labels.BUILD_TOTAL_SIZE_LABEL, BuildReportTool.Window.Settings.INFO_TITLE_STYLE_NAME); GUILayout.Label(BuildReportTool.Util.GetBuildSizePathDescription(buildReportToDisplay), BuildReportTool.Window.Settings.TINY_HELP_STYLE_NAME); GUILayout.Label(buildReportToDisplay.TotalBuildSize, BuildReportTool.Window.Settings.BIG_NUMBER_STYLE_NAME); GUILayout.EndVertical(); } GUILayout.Space(20); string emphasisColor = "black"; if (EditorGUIUtility.isProSkin || BRT_BuildReportWindow.FORCE_USE_DARK_SKIN) { emphasisColor = "white"; } string largestAssetCategoryLabel = string.Format( "<color={0}><size=20><b>{1}</b></size></color> are the largest,\ntaking up <color={0}><size=20><b>{2}%</b></size></color> of the build{3}", emphasisColor, buildReportToDisplay.BuildSizes[0].Name, buildReportToDisplay.BuildSizes[0].Percentage.ToString(CultureInfo.InvariantCulture), (!buildReportToDisplay.HasStreamingAssets ? "\n<size=12>(not counting streaming assets)</size>" : "")); GUILayout.Label(largestAssetCategoryLabel, BuildReportTool.Window.Settings.INFO_TEXT_STYLE_NAME); GUILayout.Space(20); GUILayout.EndVertical(); // 2nd column GUILayout.BeginVertical(GUILayout.MaxWidth(250)); GUILayout.Label("Made for:", BuildReportTool.Window.Settings.INFO_TITLE_STYLE_NAME); GUILayout.Label(buildReportToDisplay.BuildType, BuildReportTool.Window.Settings.INFO_SUBTITLE_STYLE_NAME); GUILayout.Label("Built in:", BuildReportTool.Window.Settings.INFO_TITLE_STYLE_NAME); GUILayout.Label(buildReportToDisplay.UnityVersionDisplayed, BuildReportTool.Window.Settings.INFO_SUBTITLE_STYLE_NAME); GUILayout.EndVertical(); DrawScenesInBuild(buildReportToDisplay.ScenesInBuild); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); var numberOfTopUsed = buildReportToDisplay.HasUsedAssets ? buildReportToDisplay.UsedAssets.NumberOfTopLargest : 0; var numberOfTopUnused = buildReportToDisplay.HasUnusedAssets ? buildReportToDisplay.UnusedAssets.NumberOfTopLargest : 0; if (Event.current.type == EventType.Layout) { _showTopUsed = numberOfTopUsed > 0 && buildReportToDisplay.UsedAssets.TopLargest != null; _showTopUnused = numberOfTopUnused > 0 && buildReportToDisplay.UnusedAssets.TopLargest != null; } // 1st column GUILayout.BeginVertical(); if (_showTopUsed) { GUILayout.Label(string.Format("Top {0} largest in build:", numberOfTopUsed.ToString()), BuildReportTool.Window.Settings.INFO_TITLE_STYLE_NAME); if (!BuildReportTool.Options.AutoResortAssetsWhenUnityEditorRegainsFocus && GUILayout.Button("Refresh", GUILayout.Height(20), GUILayout.MaxWidth(520))) { buildReportToDisplay.RecategorizeUsedAssets(); buildReportToDisplay.FlagOkToRefresh(); } DrawAssetList(buildReportToDisplay.UsedAssets, true, buildReportToDisplay, assetDependencies); } GUILayout.EndVertical(); GUILayout.Space(50); // 2nd column GUILayout.BeginVertical(); if (_showTopUnused) { GUILayout.Label(string.Format("Top {0} largest not in build:", numberOfTopUnused.ToString()), BuildReportTool.Window.Settings.INFO_TITLE_STYLE_NAME); if (!BuildReportTool.Options.AutoResortAssetsWhenUnityEditorRegainsFocus && GUILayout.Button("Refresh", GUILayout.Height(20), GUILayout.MaxWidth(520))) { buildReportToDisplay.RecategorizeUnusedAssets(); buildReportToDisplay.FlagOkToRefresh(); } DrawAssetList(buildReportToDisplay.UnusedAssets, false, buildReportToDisplay, assetDependencies); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.Space(20); if (assetDependencies != null && !string.IsNullOrEmpty(assetDependencies.SavedPath)) { GUILayout.Label("Asset Dependencies file used:", BuildReportTool.Window.Settings.SETTING_NAME_STYLE_NAME); GUILayout.Label(assetDependencies.SavedPath, BuildReportTool.Window.Settings.SETTING_VALUE_STYLE_NAME); GUILayout.Space(10); } if (textureData != null && !string.IsNullOrEmpty(textureData.SavedPath)) { GUILayout.Label("Texture Data file used:", BuildReportTool.Window.Settings.SETTING_NAME_STYLE_NAME); GUILayout.Label(textureData.SavedPath, BuildReportTool.Window.Settings.SETTING_VALUE_STYLE_NAME); GUILayout.Space(10); } if (unityBuildReport != null && !string.IsNullOrEmpty(unityBuildReport.SavedPath)) { GUILayout.Label("Additional Unity Build Report file used:", BuildReportTool.Window.Settings.SETTING_NAME_STYLE_NAME); GUILayout.Label(unityBuildReport.SavedPath, BuildReportTool.Window.Settings.SETTING_VALUE_STYLE_NAME); GUILayout.Space(10); } GUILayout.Space(20); GUILayout.EndVertical(); GUILayout.Space(20); // extra right padding GUILayout.EndHorizontal(); GUILayout.EndScrollView(); // ------------------------------------------------------ // Continually request repaint, since we need to check the rects // generated by the GUILayout (using GUILayoutUtility.GetLastRect()) // to make the hover checks work. That's because GetLastRect() only // works during repaint event. // // Later checks below can set requestRepaint to false if there's no // need to repaint, to help lessen cpu usage. requestRepaint = true; if (Event.current.mousePosition.y >= position.height || Event.current.mousePosition.y <= 0 || Event.current.mousePosition.x <= 0 || Event.current.mousePosition.x >= position.width) { // mouse is outside the window, no need to repaint, can't show tooltip anyway // set requestRepaint to false to help lessen cpu usage requestRepaint = false; } var showThumbnailNow = BuildReportTool.Options.ShowTooltipThumbnail && _shouldShowThumbnailOnHoveredAsset && (_assetUsedEntryHoveredIdx != -1 || _assetUnusedEntryHoveredIdx != -1); var zoomInChanged = false; if (showThumbnailNow) { var prevZoomedIn = BRT_BuildReportWindow.ZoomedInThumbnails; // if thumbnail is currently showing, we process the inputs // (ctrl zooms in on thumbnail, alt toggles alpha blend) BRT_BuildReportWindow.ProcessThumbnailControls(); if (prevZoomedIn != BRT_BuildReportWindow.ZoomedInThumbnails) { zoomInChanged = true; } } else { // no thumbnail currently shown. ensure the controls that // need to be reset to initial state are reset BRT_BuildReportWindow.ResetThumbnailControls(); } if (!zoomInChanged && !Event.current.alt && !BRT_BuildReportWindow.MouseMovedNow && !BRT_BuildReportWindow.LastMouseMoved) { // mouse hasn't moved, and no request to zoom-in thumbnail or toggle thumbnail alpha // no need to repaint because nothing has changed // set requestRepaint to false to help lessen cpu usage requestRepaint = false; } var shouldShowAssetEndUsersTooltipNow = BuildReportTool.Options.ShowAssetPrimaryUsersInTooltipIfAvailable && BRT_BuildReportWindow.ShouldHoveredAssetShowEndUserTooltip( assetDependencies) && (_assetUsedEntryHoveredIdx != -1 || _assetUnusedEntryHoveredIdx != -1); if (Event.current.type == EventType.Repaint) { if (showThumbnailNow && shouldShowAssetEndUsersTooltipNow) { // draw thumbnail and end users below it BRT_BuildReportWindow.DrawThumbnailEndUsersTooltip(position, assetDependencies, textureData); } else if (shouldShowAssetEndUsersTooltipNow) { // draw only end users in tooltip BRT_BuildReportWindow.DrawEndUsersTooltip(position, assetDependencies); } else if (showThumbnailNow) { // draw only thumbnail in tooltip BRT_BuildReportWindow.DrawThumbnailTooltip(position, textureData); } } }
public override void DrawGUI(Rect position, BuildInfo buildReportToDisplay) { GUILayout.Space(2); // top padding for scrollbar _scrollPos = GUILayout.BeginScrollView(_scrollPos); GUILayout.BeginHorizontal(); GUILayout.Space(10); // extra left padding GUILayout.BeginVertical(); GUILayout.Space(10); // top padding // report title GUILayout.Label(buildReportToDisplay.SuitableTitle, BuildReportTool.Window.Settings.MAIN_TITLE_STYLE_NAME); GUILayout.Space(10); // two-column layout GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.BeginVertical(GUILayout.MaxWidth(350)); GUILayout.Label(Labels.TIME_OF_BUILD_LABEL, BuildReportTool.Window.Settings.INFO_TITLE_STYLE_NAME); GUILayout.Label(buildReportToDisplay.GetTimeReadable(), BuildReportTool.Window.Settings.INFO_SUBTITLE_STYLE_NAME); GUILayout.Label("Report generation took:", BuildReportTool.Window.Settings.INFO_TITLE_STYLE_NAME); GUILayout.Label(buildReportToDisplay.ReportGenerationTime.ToString(), BuildReportTool.Window.Settings.INFO_SUBTITLE_STYLE_NAME); BuildReportTool.Window.Utility.DrawLargeSizeDisplay(Labels.BUILD_TOTAL_SIZE_LABEL, BuildReportTool.Window.Utility.GetProperBuildSizeDesc(buildReportToDisplay), buildReportToDisplay.TotalBuildSize); GUILayout.Space(20); string emphasisColor = "black"; if (EditorGUIUtility.isProSkin) { emphasisColor = "white"; } GUILayout.Label("<color=" + emphasisColor + "><size=20><b>" + buildReportToDisplay.BuildSizes[1].Name + "</b></size></color> are the largest,\ntaking up <color=" + emphasisColor + "><size=20><b>" + buildReportToDisplay.BuildSizes[1].Percentage + "%</b></size></color> of the build" + (buildReportToDisplay.HasStreamingAssets ? "\n<size=12>(not counting streaming assets)</size>" : ""), BuildReportTool.Window.Settings.INFO_TEXT_STYLE_NAME); GUILayout.Space(20); GUILayout.EndVertical(); GUILayout.BeginVertical(GUILayout.MaxWidth(350)); GUILayout.Label("Made for:", BuildReportTool.Window.Settings.INFO_TITLE_STYLE_NAME); GUILayout.Label(buildReportToDisplay.BuildType, BuildReportTool.Window.Settings.INFO_SUBTITLE_STYLE_NAME); GUILayout.Label("Built in:", BuildReportTool.Window.Settings.INFO_TITLE_STYLE_NAME); GUILayout.Label(buildReportToDisplay.UnityVersionDisplayed, BuildReportTool.Window.Settings.INFO_SUBTITLE_STYLE_NAME); GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (buildReportToDisplay.HasUsedAssets) { GUILayout.BeginVertical(); GUILayout.Label("Top ten largest in build:", BuildReportTool.Window.Settings.INFO_TITLE_STYLE_NAME); DrawAssetList(buildReportToDisplay.UsedAssets); GUILayout.EndVertical(); } if (buildReportToDisplay.HasUsedAssets && buildReportToDisplay.HasUnusedAssets) { GUILayout.Space(50); } if (buildReportToDisplay.HasUnusedAssets) { GUILayout.BeginVertical(); GUILayout.Label("Top ten largest not in build:", BuildReportTool.Window.Settings.INFO_TITLE_STYLE_NAME); DrawAssetList(buildReportToDisplay.UnusedAssets); GUILayout.EndVertical(); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.Space(20); GUILayout.EndVertical(); GUILayout.Space(20); // extra right padding GUILayout.EndHorizontal(); GUILayout.EndScrollView(); }
public override void DrawGUI(Rect position, BuildInfo buildReportToDisplay) { GUILayout.Space(2); // top padding for scrollbar _scrollPos = GUILayout.BeginScrollView(_scrollPos); GUILayout.BeginHorizontal(); GUILayout.Space(10); // extra left padding GUILayout.BeginVertical(); GUILayout.Space(10); // top padding // report title GUILayout.Label(buildReportToDisplay.SuitableTitle, BuildReportTool.Window.Settings.MAIN_TITLE_STYLE_NAME); GUILayout.Space(10); // two-column layout GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.BeginVertical(GUILayout.MaxWidth(350)); GUILayout.Label(Labels.TIME_OF_BUILD_LABEL, BuildReportTool.Window.Settings.INFO_TITLE_STYLE_NAME); GUILayout.Label(buildReportToDisplay.GetTimeReadable(), BuildReportTool.Window.Settings.INFO_SUBTITLE_STYLE_NAME); GUILayout.Label("Report generation took:", BuildReportTool.Window.Settings.INFO_TITLE_STYLE_NAME); GUILayout.Label(buildReportToDisplay.ReportGenerationTime.ToString(), BuildReportTool.Window.Settings.INFO_SUBTITLE_STYLE_NAME); BuildReportTool.Window.Utility.DrawLargeSizeDisplay(Labels.BUILD_TOTAL_SIZE_LABEL, BuildReportTool.Window.Utility.GetProperBuildSizeDesc(buildReportToDisplay), buildReportToDisplay.TotalBuildSize); GUILayout.Space(20); string emphasisColor = "black"; if (EditorGUIUtility.isProSkin) { emphasisColor = "white"; } GUILayout.Label("<color=" + emphasisColor + "><size=20><b>" + buildReportToDisplay.BuildSizes[1].Name + "</b></size></color> are the largest,\ntaking up <color=" + emphasisColor + "><size=20><b>" + buildReportToDisplay.BuildSizes[1].Percentage + "%</b></size></color> of the build" + (buildReportToDisplay.HasStreamingAssets ? "\n<size=12>(not counting streaming assets)</size>" : ""), BuildReportTool.Window.Settings.INFO_TEXT_STYLE_NAME); GUILayout.Space(20); GUILayout.EndVertical(); GUILayout.BeginVertical(GUILayout.MaxWidth(350)); GUILayout.Label("Made for:", BuildReportTool.Window.Settings.INFO_TITLE_STYLE_NAME); GUILayout.Label(buildReportToDisplay.BuildType, BuildReportTool.Window.Settings.INFO_SUBTITLE_STYLE_NAME); GUILayout.Label("Built in:", BuildReportTool.Window.Settings.INFO_TITLE_STYLE_NAME); GUILayout.Label(buildReportToDisplay.UnityVersionDisplayed, BuildReportTool.Window.Settings.INFO_SUBTITLE_STYLE_NAME); GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (buildReportToDisplay.HasUsedAssets) { GUILayout.BeginVertical(); GUILayout.Label("Top ten largest in build:", BuildReportTool.Window.Settings.INFO_TITLE_STYLE_NAME); DrawAssetList(buildReportToDisplay.UsedAssets); GUILayout.EndVertical(); } if (buildReportToDisplay.HasUsedAssets && buildReportToDisplay.HasUnusedAssets) { GUILayout.Space(50); } if (buildReportToDisplay.HasUnusedAssets) { GUILayout.BeginVertical(); GUILayout.Label("Top ten largest not in build:", BuildReportTool.Window.Settings.INFO_TITLE_STYLE_NAME); DrawAssetList(buildReportToDisplay.UnusedAssets); GUILayout.EndVertical(); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.Space(20); GUILayout.EndVertical(); GUILayout.Space(20); // extra right padding GUILayout.EndHorizontal(); GUILayout.EndScrollView(); }