Provides a high-level summary of the content included in a build.
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
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()); } }
| 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 .resS and .resource files. |
| resourceFileCount | Number of resource files (.resS and .resource extensions) in the build output. |
| 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. |
| Property | Description |
|---|---|
| hideFlags | Should the object be hidden, saved with the Scene or modifiable by the user? |
| name | The name of the object. |
| Method | Description |
|---|---|
| GetEntityId | Gets the EntityId of the object. |
| ToString | Returns the name of the object. |
| Method | Description |
|---|---|
| Destroy | Removes a GameObject, component, or asset. |
| DestroyImmediate | Destroys the specified object immediately. Use with caution and in Edit mode only. |
| DontDestroyOnLoad | Do not destroy the target Object when loading a new Scene. |
| FindAnyObjectByType | Retrieves any active loaded object of Type type. |
| FindObjectsByType | Retrieves a list of all loaded objects of Type type. |
| Instantiate | Clones the object original and returns the clone. |
| InstantiateAsync | Captures a snapshot of the original object (that must be related to some GameObject) and returns the AsyncInstantiateOperation. |
| Operator | Description |
|---|---|
| bool | Does the object exist? |
| operator != | Compares if two objects refer to a different object. |
| operator == | Compares two object references to see if they refer to the same object. |