Cook.AllowContentValidation

Cook.AllowContentValidation

#Overview

name: Cook.AllowContentValidation

This variable is created as a Console Variable (cvar).

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of Cook.AllowContentValidation is to control whether content validation can be run during the cooking process in Unreal Engine 5. It is primarily used in the cooking system, which is responsible for preparing game content for distribution.

This setting variable is mainly used in the UnrealEd module, specifically within the CookCommandlet class. The CookCommandlet is part of the engine’s build and packaging system, used to prepare game content for different platforms.

The value of this variable is set using an FAutoConsoleVariableRef, which means it can be modified at runtime through console commands. By default, it is set to true.

The associated variable bAllowContentValidation directly interacts with Cook.AllowContentValidation. They share the same value, with bAllowContentValidation being the actual boolean variable used in the code logic.

Developers must be aware that this variable acts as a master switch for content validation during cooking. Even if specific validation options are requested (like RunAssetValidation or RunMapValidation), they will only be executed if Cook.AllowContentValidation is set to true.

Best practices when using this variable include:

  1. Keep it enabled (true) during development to catch content issues early.
  2. Consider disabling it for final builds or when cooking time is critical, as validation can increase cooking time.
  3. Use in conjunction with specific validation switches (RunAssetValidation, RunMapValidation) for more granular control.

Regarding the associated variable bAllowContentValidation:

The purpose of bAllowContentValidation is to serve as the actual boolean flag used in the code logic to determine if content validation should be allowed during cooking.

It is used within the CookCommandlet class in the UnrealEd module, specifically in the CookByTheBook function.

The value of bAllowContentValidation is set through the FAutoConsoleVariableRef mechanism, which binds it to the Cook.AllowContentValidation console variable.

This variable directly interacts with the Cook.AllowContentValidation console variable, effectively serving as its in-code representation.

Developers should be aware that modifying bAllowContentValidation directly in code will not affect the console variable. Changes should be made through the Cook.AllowContentValidation console command for consistency.

Best practices for using bAllowContentValidation include:

  1. Avoid modifying it directly in code; use the console variable instead.
  2. Use it as a guard for content validation logic in cooking-related code.
  3. Consider exposing it in user-facing cook settings if fine-grained control over validation is needed.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Commandlets/CookCommandlet.cpp:68

Scope (from outer to inner):

file
namespace    UE::Cook

Source code excerpt:

bool bAllowContentValidation = true;
FAutoConsoleVariableRef AllowContentValidationCVar(
	TEXT("Cook.AllowContentValidation"),
	bAllowContentValidation,
	TEXT("True to allow content validation to run during cook (if requested), or false to disable it."));

}

UCookCommandlet::UCookCommandlet( const FObjectInitializer& ObjectInitializer )

#Associated Variable and Callsites

This variable is associated with another variable named bAllowContentValidation. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Commandlets/CookCommandlet.cpp:66

Scope (from outer to inner):

file
namespace    UE::Cook

Source code excerpt:

};

bool bAllowContentValidation = true;
FAutoConsoleVariableRef AllowContentValidationCVar(
	TEXT("Cook.AllowContentValidation"),
	bAllowContentValidation,
	TEXT("True to allow content validation to run during cook (if requested), or false to disable it."));

}

UCookCommandlet::UCookCommandlet( const FObjectInitializer& ObjectInitializer )
	: Super(ObjectInitializer)

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Commandlets/CookCommandlet.cpp:413

Scope (from outer to inner):

file
function     bool UCookCommandlet::CookByTheBook

Source code excerpt:

	bool bCookList = Switches.Contains(TEXT("CookList"));

	if (UE::Cook::bAllowContentValidation)
	{
		CookOptions |= Switches.Contains(TEXT("RunAssetValidation")) ? ECookByTheBookOptions::RunAssetValidation : ECookByTheBookOptions::None;
		CookOptions |= Switches.Contains(TEXT("RunMapValidation")) ? ECookByTheBookOptions::RunMapValidation : ECookByTheBookOptions::None;
		CookOptions |= Switches.Contains(TEXT("ValidationErrorsAreFatal")) ? ECookByTheBookOptions::ValidationErrorsAreFatal : ECookByTheBookOptions::None;
	}