Version: Unity 6.6 Alpha (6000.6)
LanguageEnglish
  • C#

ContentSummary

class in UnityEditor.Build.Reporting

/

Inherits from:Object

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

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()); } }

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 .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.

Inherited Members

Properties

PropertyDescription
hideFlagsShould the object be hidden, saved with the Scene or modifiable by the user?
nameThe name of the object.

Public Methods

MethodDescription
GetEntityIdGets the EntityId of the object.
ToStringReturns the name of the object.

Static Methods

MethodDescription
DestroyRemoves a GameObject, component, or asset.
DestroyImmediateDestroys the specified object immediately. Use with caution and in Edit mode only.
DontDestroyOnLoadDo not destroy the target Object when loading a new Scene.
FindAnyObjectByTypeRetrieves any active loaded object of Type type.
FindObjectsByTypeRetrieves a list of all loaded objects of Type type.
InstantiateClones the object original and returns the clone.
InstantiateAsyncCaptures a snapshot of the original object (that must be related to some GameObject) and returns the AsyncInstantiateOperation.

Operators

OperatorDescription
boolDoes 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.