bShouldAcquireMissingChunksOnLoad

bShouldAcquireMissingChunksOnLoad

#Overview

name: bShouldAcquireMissingChunksOnLoad

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 7 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of bShouldAcquireMissingChunksOnLoad is to control whether the Asset Manager should attempt to acquire missing chunks when loading assets in Unreal Engine 5. This setting is primarily used for the asset management and streaming system.

This setting variable is primarily relied upon by the Asset Manager subsystem within the Engine module. It is used in the UAssetManager class, which is responsible for managing and loading assets in the engine.

The value of this variable is set in multiple places:

  1. It is initialized to false in the UAssetManager constructor.
  2. It is set based on the value in UAssetManagerSettings during UAssetManager::PostInitProperties.
  3. It can be updated through the ReinitializeFromConfig function of UAssetManager.

This variable interacts with other asset management-related variables and functions, such as LoadAssetList and FindMissingChunkList.

Developers must be aware that this setting is primarily intended for use in cooked builds where assets are packaged into pak files. It’s not applicable in editor or non-cooked builds.

Best practices when using this variable include:

  1. Only enable it in cooked builds where chunk-based asset streaming is implemented.
  2. Ensure that the chunk install interface is properly set up when this option is enabled.
  3. Be prepared to handle cases where chunks cannot be acquired, as seen in the LoadAssetList function.
  4. Consider the performance implications of enabling this feature, as it may introduce additional checks and potential network requests during asset loading.

#Setting Variables

#References In INI files

Location: <Workspace>/Projects/Lyra/Config/DefaultGame.ini:55, section: [/Script/Engine.AssetManagerSettings]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Engine/AssetManager.h:819

Scope (from outer to inner):

file
class        class UAssetManager : public UObject

Source code excerpt:

	/** True if the chunk install interface should be queries before loading assets */
	UPROPERTY()
	bool bShouldAcquireMissingChunksOnLoad;

	/** If true, DevelopmentCook assets will error when they are cooked */
	UPROPERTY()
	bool bOnlyCookProductionAssets;

	/** Suppresses bOnlyCookProductionAssets based on the AllowsDevelopmentObjects() property of the TargetPlatforms being cooked. */

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Engine/AssetManagerSettings.h:72

Scope (from outer to inner):

file
class        class UAssetManagerSettings : public UDeveloperSettings
function     UAssetManagerSettings

Source code excerpt:

	: bOnlyCookProductionAssets(false)
	, bShouldGuessTypeAndNameInEditor(true)
	, bShouldAcquireMissingChunksOnLoad(false) 
	, bShouldWarnAboutInvalidAssets(true)
	{}

	/** List of asset types to scan at startup */
	UPROPERTY(config, EditAnywhere, Category = "Asset Manager", meta = (TitleProperty = "PrimaryAssetType"))
	TArray<FPrimaryAssetTypeInfo> PrimaryAssetTypesToScan;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Engine/AssetManagerSettings.h:112

Scope (from outer to inner):

file
class        class UAssetManagerSettings : public UDeveloperSettings

Source code excerpt:

	/** If true, this will query the platform chunk install interface to request missing chunks for any requested primary asset loads */
	UPROPERTY(config, EditAnywhere, Category = "Asset Manager")
	bool bShouldAcquireMissingChunksOnLoad;

	/** If true, the asset manager will warn when it is told to load or do something with assets it does not know about */
	UPROPERTY(config, EditAnywhere, Category = "Asset Manager")
	bool bShouldWarnAboutInvalidAssets;

	/** Redirect from Type:Name to Type:NameNew */

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AssetManager.cpp:369

Scope (from outer to inner):

file
function     UAssetManager::UAssetManager

Source code excerpt:

	bShouldUseSynchronousLoad = false;
	bIsLoadingFromPakFiles = false;
	bShouldAcquireMissingChunksOnLoad = false;
	bTargetPlatformsAllowDevelopmentObjects = false;
	NumBulkScanRequests = 0;
	bIsManagementDatabaseCurrent = false;
	bIsPrimaryAssetDirectoryCurrent = false;
	bUpdateManagementDatabaseAfterScan = false;
	bIncludeOnlyOnDiskAssets = true;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AssetManager.cpp:430

Scope (from outer to inner):

file
function     void UAssetManager::PostInitProperties

Source code excerpt:

		// Only cooked builds supoprt pak files and chunk download
		bIsLoadingFromPakFiles = FPlatformFileManager::Get().FindPlatformFile(TEXT("PakFile")) != nullptr;
		bShouldAcquireMissingChunksOnLoad = Settings.bShouldAcquireMissingChunksOnLoad;
#endif
		
		bShouldUseSynchronousLoad = IsRunningCommandlet();

		if (Settings.bShouldManagerDetermineTypeAndName)
		{

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AssetManager.cpp:2203

Scope (from outer to inner):

file
function     TSharedPtr<FStreamableHandle> UAssetManager::LoadAssetList

Source code excerpt:

	TArray<int32> MissingChunks, ErrorChunks;

	if (bShouldAcquireMissingChunksOnLoad)
	{
		FindMissingChunkList(AssetList, MissingChunks, ErrorChunks);

		if (ErrorChunks.Num() > 0)
		{
			// At least one chunk doesn't exist, fail

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AssetManager.cpp:4699

Scope (from outer to inner):

file
function     void UAssetManager::ReinitializeFromConfig

Source code excerpt:

	const UAssetManagerSettings& Settings = GetSettings();
	bShouldGuessTypeAndName = Settings.bShouldGuessTypeAndNameInEditor;
	bShouldAcquireMissingChunksOnLoad = Settings.bShouldAcquireMissingChunksOnLoad;
	bOnlyCookProductionAssets = Settings.bOnlyCookProductionAssets;

	if (FCoreUObjectDelegates::GetPrimaryAssetIdForObject.IsBoundToObject(this))
	{
		FCoreUObjectDelegates::GetPrimaryAssetIdForObject.Unbind();
	}