Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


ContentSummary

Provides a high-level summary of the content included in a build.
Read time 5 minutesLast updated 8 days ago

Definition

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.

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

assetStatsReturns an array with statistics for each source Asset that contributed content to the build output.
headerSizeTotal size, in bytes, of the header sections across all serialized files in the build output.
objectCountTotal number of objects that have been serialized in the build output.
resourceDataSizeTotal size, in bytes, of the binary data stored in
.resS
and
.resource
files.
resourceFileCountNumber of resource files (
.resS
and
.resource
extensions) in the build output.
reusedSerializedFileCountNumber of serialized files reused from previous builds rather than rebuilt.
reusedSerializedFileSizeSize, in bytes, of the serialized files reused from previous builds rather than rebuilt.
serializedFileCountNumber of serialized files in the build output.
serializedFileSizeTotal size, in bytes, of the serialized files in the build output.
typeStatsReturns an array containing statistics for each Unity Object type included in the build.

Inheritance

Inherited Members

Operators

Operator

Description

operator ==Compares two object references to see if they refer to the same object.
boolDetermines whether the object exists.
operator !=Compares if two objects refer to a different object.