ContentSummary
Provides a high-level summary of the content included in a build.
Read time 5 minutesLast updated 8 days ago
Definition
- Type: Class
- Namespace: UnityEditor.Build.Reporting
- Assembly: UnityEditor.CoreModule
- Inherits from: Object
public sealed class ContentSummary : Object
Remarks
ContentSummary provides a compact overview of build content that is more efficient to work with than the detailed PackedAssets data. It includes aggregate statistics such as total sizes, object counts, and breakdowns by Unity Object type and source Asset.
ContentSummary is populated for Player builds, AssetBundle builds, and ContentDirectory builds. It is not populated for scripts-only Player builds (see BuildOptions.BuildScriptsOnly).
For incremental AssetBundle builds, the statistics only reflect the content of the AssetBundles that were rebuilt in the current build invocation. AssetBundles that were unchanged and reused from previous build results are not included.
Additional Resources: BuildPipeline.BuildContentDirectory, BuildReport
Examples
using System.Text;using UnityEditor;using UnityEditor.Build;using UnityEditor.Build.Reporting;using UnityEngine;/// <summary>/// Example showing how to use ContentSummary to track build content size over time./// </summary>public class ContentSummaryExample{ [MenuItem("Example/BuildHistory/Print Content Size History")] static public void PrintContentSizeHistory() { GUID[] allBuilds = BuildHistory.GetAllBuilds(); if (allBuilds.Length == 0) { Debug.Log("No builds found in build history."); return; } var sb = new StringBuilder(); sb.AppendLine("=== Player Build Content Size History ==="); int playerBuildCount = 0; // Iterate builds in reverse order (most recent first) for (int i = allBuilds.Length - 1; i >= 0; i--) { BuildReportSummary summary = BuildHistory.GetBuildSummary(allBuilds[i]); if (summary.BuildType != BuildType.Player || summary.BuildResult != BuildResult.Succeeded) continue; BuildReport report = BuildHistory.LoadBuildReport(allBuilds[i]); if (report == null) continue; ContentSummary contentSummary = report.contentSummary; if (contentSummary == null) continue; playerBuildCount++; ulong totalContentSize = contentSummary.serializedFileSize + contentSummary.resourceDataSize; sb.AppendLine($" {summary.BuildStartedAt} {summary.PlatformName,-20} " + $"Objects: {contentSummary.objectCount,6} " + $"Content size: {totalContentSize,12} bytes"); } if (playerBuildCount == 0) sb.AppendLine(" No successful Player builds with content summaries found."); Debug.Log(sb.ToString()); }}
Properties
Property | Description |
|---|---|
| assetStats | Returns an array with statistics for each source Asset that contributed content to the build output. |
| headerSize | Total size, in bytes, of the header sections across all serialized files in the build output. |
| objectCount | Total number of objects that have been serialized in the build output. |
| resourceDataSize | Total size, in bytes, of the binary data stored in |
| resourceFileCount | Number of resource files ( |
| reusedSerializedFileCount | Number of serialized files reused from previous builds rather than rebuilt. |
| reusedSerializedFileSize | Size, in bytes, of the serialized files reused from previous builds rather than rebuilt. |
| serializedFileCount | Number of serialized files in the build output. |
| serializedFileSize | Total size, in bytes, of the serialized files in the build output. |
| typeStats | Returns an array containing statistics for each Unity Object type included in the build. |
Inheritance
Operators
Operator | Description |
|---|---|
| operator == | Compares two object references to see if they refer to the same object. |
| bool | Determines whether the object exists. |
| operator != | Compares if two objects refer to a different object. |