WriteBackMetadataToAssetRegistry

WriteBackMetadataToAssetRegistry

#Overview

name: WriteBackMetadataToAssetRegistry

The value of this variable can be defined or overridden in .ini config files. 1 .ini config file referencing this setting variable.

It is referenced in 5 C++ source files. Also referenced in 1 C# build file meaning it may affect the build system logic.

#Summary

#Usage in the C++ source code

The purpose of WriteBackMetadataToAssetRegistry is to control how and if metadata is written back to the Asset Registry during the packaging process in Unreal Engine 5. This setting is primarily used in the packaging and IO system of the engine.

This setting variable is relied upon by the IoStoreUtilities module, which is part of Unreal Engine’s IO system. It’s specifically used in the process of creating IO Store container files, which are used for efficient asset loading and management.

The value of this variable is set in the ProjectPackagingSettings class, which suggests it can be configured through the project settings in the Unreal Editor. It’s defined as a UPROPERTY, making it accessible and editable in the editor interface.

WriteBackMetadataToAssetRegistry interacts with another boolean variable, bWritePluginSizeSummaryJsons. The latter is only considered when WriteBackMetadataToAssetRegistry is not set to Disabled.

Developers must be aware that this variable has three possible values:

  1. AdjacentFile
  2. OriginalFile
  3. Disabled

Each of these options affects how the metadata is written back to the Asset Registry. The choice can impact the packaging process and potentially the runtime performance of the game.

Best practices when using this variable include:

  1. Carefully consider the implications of each option on your project’s specific needs.
  2. Ensure that the chosen option aligns with your asset management and loading strategies.
  3. Be mindful of potential performance impacts, especially when deciding between writing to the original file or an adjacent file.
  4. If using the AdjacentFile or OriginalFile options, consider also enabling bWritePluginSizeSummaryJsons for more comprehensive metadata.
  5. When modifying this setting, test thoroughly to ensure it doesn’t negatively impact your project’s loading times or overall performance.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseGame.ini:116, section: [/Script/UnrealEd.ProjectPackagingSettings]

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Developer/DeveloperToolSettings/Classes/Settings/ProjectPackagingSettings.h:324

Scope (from outer to inner):

file
class        class UProjectPackagingSettings : public UObject

Source code excerpt:

	*/
	UPROPERTY(config, EditAnywhere, Category = Packaging, AdvancedDisplay)
	EAssetRegistryWritebackMethod WriteBackMetadataToAssetRegistry;

	/**
	* Whether or not to write a json summary file that contains size information to the cooked Metadata/PluginJsons directory
	*/
	UPROPERTY(config, EditAnywhere, Category = Packaging, AdvancedDisplay, meta = (EditCondition = "WriteBackMetadataToAssetRegistry != EAssetRegistryWritebackMethod::Disabled"))
	bool bWritePluginSizeSummaryJsons;

#Loc: <Workspace>/Engine/Source/Developer/IoStoreUtilities/Private/IoStoreUtilities.cpp:1032

Scope: file

Source code excerpt:

	bool bFileRegions = false;
	bool bUpload = false;
	EAssetRegistryWritebackMethod WriteBackMetadataToAssetRegistry = EAssetRegistryWritebackMethod::Disabled;
	bool bWritePluginSizeSummaryJsons = false; // Only valid if WriteBackMetadataToAssetRegistry != Disabled.

	FOodleDataCompression::ECompressor ShaderOodleCompressor = FOodleDataCompression::ECompressor::Mermaid;
	FOodleDataCompression::ECompressionLevel ShaderOodleLevel = FOodleDataCompression::ECompressionLevel::Normal;

	bool IsDLC() const
	{

#Loc: <Workspace>/Engine/Source/Developer/IoStoreUtilities/Private/IoStoreUtilities.cpp:5587

Scope (from outer to inner):

file
function     int32 CreateTarget

Source code excerpt:

	}

	if (Arguments.WriteBackMetadataToAssetRegistry != EAssetRegistryWritebackMethod::Disabled)
	{
		DoAssetRegistryWritebackDuringStage(
			Arguments.WriteBackMetadataToAssetRegistry, 
			Arguments.bWritePluginSizeSummaryJsons, 
			Arguments.CookedDir, 
			GeneralIoWriterSettings.CompressionMethod != NAME_None, 
			IoStoreWriters, 
			IoStoreWriterInfos,
			ShaderAssocInfo);

#Loc: <Workspace>/Engine/Source/Developer/IoStoreUtilities/Private/IoStoreUtilities.cpp:9328

Scope (from outer to inner):

file
function     int32 CreateIoStoreContainerFiles

Source code excerpt:

		// Opens a given directory of containers and a given asset registry, and adds chunk size information
		// for an asset's package to its asset tags in the asset registry. This can also be done during the staging
		// process with -WriteBackMetadataToAssetRegistry (below).
		//
		FString AssetRegistryFileName = MoveTemp(ArgumentValue);
		FString PathToContainers;
		if (!FParse::Value(FCommandLine::Get(), TEXT("ContainerDirectory="), PathToContainers))
		{
			UE_LOG(LogIoStore, Error, TEXT("Asset registry writeback requires -ContainerDirectory=Path/To/Containers"));

#Loc: <Workspace>/Engine/Source/Developer/IoStoreUtilities/Private/IoStoreUtilities.cpp:9593

Scope (from outer to inner):

file
function     int32 CreateIoStoreContainerFiles

Source code excerpt:

	// Whether or not to write compressed asset sizes back to the asset registry.

	FString WriteBackMetadataToAssetRegistry;
	if (FParse::Value(FCommandLine::Get(), TEXT("WriteBackMetadataToAssetRegistry="), WriteBackMetadataToAssetRegistry))
	{
		// StaticEnum not available in UnrealPak, so manual conversion:
		if (WriteBackMetadataToAssetRegistry.Equals(TEXT("AdjacentFile"), ESearchCase::IgnoreCase))
		{
			Arguments.WriteBackMetadataToAssetRegistry = EAssetRegistryWritebackMethod::AdjacentFile;
		}
		else if (WriteBackMetadataToAssetRegistry.Equals(TEXT("OriginalFile"), ESearchCase::IgnoreCase))
		{
			Arguments.WriteBackMetadataToAssetRegistry = EAssetRegistryWritebackMethod::OriginalFile;
		}
		else if (WriteBackMetadataToAssetRegistry.Equals(TEXT("Disabled"), ESearchCase::IgnoreCase))
		{
			Arguments.WriteBackMetadataToAssetRegistry = EAssetRegistryWritebackMethod::Disabled;
		}
		else
		{
			UE_LOG(LogIoStore, Error, TEXT("Invalid WriteBackMetdataToAssetRegistry value: %s - check setting in ProjectSettings -> Packaging"), *WriteBackMetadataToAssetRegistry);
			UE_LOG(LogIoStore, Error, TEXT("Valid options are: AdjacentFile, OriginalFile, Disabled."), *WriteBackMetadataToAssetRegistry);
			return -1;
		}

		Arguments.bWritePluginSizeSummaryJsons = FParse::Param(FCommandLine::Get(), TEXT("WritePluginSizeSummaryJsons"));
	}

#References in C# build files

This variable is referenced in the following C# build files:

Location: <Workspace>/Engine/Source/Programs/AutomationTool/Scripts/CopyBuildToStagingDirectory.Automation.cs:3711

				{
					string WriteBackMetadataToAssetRegistry;
					if (PlatformGameConfig.GetString("/Script/UnrealEd.ProjectPackagingSettings", "WriteBackMetadataToAssetRegistry", out WriteBackMetadataToAssetRegistry))
					{
						AdditionalArgs += " -WriteBackMetadataToAssetRegistry=" + WriteBackMetadataToAssetRegistry;
					}

					bool bWritePluginSizeSummaryJsons = false;
					if (PlatformGameConfig.GetBool("/Script/UnrealEd.ProjectPackagingSettings", "bWritePluginSizeSummaryJsons", out bWritePluginSizeSummaryJsons) &&