ModulesToPreload
ModulesToPreload
#Overview
name: ModulesToPreload
The value of this variable can be defined or overridden in .ini config files. 15
.ini config files referencing this setting variable.
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of ModulesToPreload is to specify a list of modules that need to be loaded before processing localization-related tasks in Unreal Engine 5. This setting variable is primarily used in the context of localization and text gathering processes.
The Unreal Engine subsystems that rely on this setting variable are primarily the Localization system and the Editor’s commandlet system, specifically for gathering text from assets and metadata. This can be seen from the file locations where the variable is referenced, such as Localization/Private/LocalizationConfigurationScript.cpp and UnrealEd/Private/Commandlets/GatherTextFromAssetsCommandlet.cpp.
The value of this variable is set in two ways:
- Through the localization target settings in the engine’s UI, where users can specify required module names.
- Via configuration files, which are parsed using the ConfigureFromScript function in the GatherTextFromAssetsCommandlet.
This variable interacts with the FModuleManager class, which is responsible for loading the specified modules. It also indirectly interacts with other localization-related variables like IncludePathFilters and ExcludePathFilters.
Developers must be aware that:
- The modules specified in ModulesToPreload must exist and be valid, or the engine will log errors during the text gathering process.
- Loading unnecessary modules may impact performance, so only required modules should be included.
Best practices when using this variable include:
- Only specify modules that are absolutely necessary for the localization process.
- Ensure that all specified modules are available in the project to avoid load failures.
- Keep the list of modules up-to-date as the project evolves, removing any that become unnecessary.
- Use this in conjunction with other localization settings for a comprehensive localization strategy.
- Test the localization process thoroughly after modifying this variable to ensure all required text is gathered correctly.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Config/Localization/Category.ini:27, section: [GatherTextStep0]
- INI Section:
GatherTextStep0
- Raw value:
OutputLog
- Is Array:
False
Location: <Workspace>/Engine/Config/Localization/Category.ini:28, section: [GatherTextStep0]
- INI Section:
GatherTextStep0
- Raw value:
StructViewer
- Is Array:
False
Location: <Workspace>/Engine/Config/Localization/Category.ini:29, section: [GatherTextStep0]
- INI Section:
GatherTextStep0
- Raw value:
MeshPaintMode
- Is Array:
False
Location: <Workspace>/Engine/Config/Localization/Category.ini:30, section: [GatherTextStep0]
- INI Section:
GatherTextStep0
- Raw value:
LandscapeEditor
- Is Array:
False
Location: <Workspace>/Engine/Config/Localization/Editor.ini:54, section: [GatherTextStep2]
- INI Section:
GatherTextStep2
- Raw value:
StructViewer
- Is Array:
False
Location: <Workspace>/Engine/Config/Localization/Editor.ini:55, section: [GatherTextStep2]
- INI Section:
GatherTextStep2
- Raw value:
MeshPaintMode
- Is Array:
False
Location: <Workspace>/Engine/Config/Localization/Editor.ini:56, section: [GatherTextStep2]
- INI Section:
GatherTextStep2
- Raw value:
LandscapeEditor
- Is Array:
False
Location: <Workspace>/Engine/Config/Localization/PropertyNames.ini:27, section: [GatherTextStep0]
- INI Section:
GatherTextStep0
- Raw value:
OutputLog
- Is Array:
False
Location: <Workspace>/Engine/Config/Localization/PropertyNames.ini:28, section: [GatherTextStep0]
- INI Section:
GatherTextStep0
- Raw value:
StructViewer
- Is Array:
False
Location: <Workspace>/Engine/Config/Localization/PropertyNames.ini:29, section: [GatherTextStep0]
- INI Section:
GatherTextStep0
- Raw value:
MeshPaintMode
- Is Array:
False
Location: <Workspace>/Engine/Config/Localization/PropertyNames.ini:30, section: [GatherTextStep0]
- INI Section:
GatherTextStep0
- Raw value:
LandscapeEditor
- Is Array:
False
Location: <Workspace>/Engine/Config/Localization/ToolTips.ini:27, section: [GatherTextStep0]
- INI Section:
GatherTextStep0
- Raw value:
OutputLog
- Is Array:
False
Location: <Workspace>/Engine/Config/Localization/ToolTips.ini:28, section: [GatherTextStep0]
- INI Section:
GatherTextStep0
- Raw value:
StructViewer
- Is Array:
False
Location: <Workspace>/Engine/Config/Localization/ToolTips.ini:29, section: [GatherTextStep0]
- INI Section:
GatherTextStep0
- Raw value:
MeshPaintMode
- Is Array:
False
Location: <Workspace>/Engine/Config/Localization/ToolTips.ini:30, section: [GatherTextStep0]
- INI Section:
GatherTextStep0
- Raw value:
LandscapeEditor
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Developer/Localization/Private/LocalizationConfigurationScript.cpp:301
Scope (from outer to inner):
file
namespace LocalizationConfigurationScript
function FLocalizationConfigurationScript GenerateGatherTextConfigFile
Source code excerpt:
for (const FString& ModuleName : Target->Settings.RequiredModuleNames)
{
ConfigSection.Add( TEXT("ModulesToPreload"), ModuleName );
}
const FString SourcePath = ContentDirRelativeToGameDir / TEXT("Localization") / Target->Settings.Name;
ConfigSection.Add( TEXT("SourcePath"), SourcePath );
const FString DestinationPath = ContentDirRelativeToGameDir / TEXT("Localization") / Target->Settings.Name;
ConfigSection.Add( TEXT("DestinationPath"), DestinationPath );
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Classes/Commandlets/GatherTextFromAssetsCommandlet.h:103
Scope (from outer to inner):
file
class class UGatherTextFromAssetsCommandlet : public UGatherTextCommandletBase
Source code excerpt:
static const FString UsageText;
TArray<FString> ModulesToPreload;
TArray<FString> IncludePathFilters;
TArray<FString> CollectionFilters;
TArray<FString> ExcludePathFilters;
TArray<FString> PackageFileNameFilters;
TArray<FString> ExcludeClassNames;
TArray<FString> ManifestDependenciesList;
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Commandlets/GatherTextFromAssetsCommandlet.cpp:884
Scope (from outer to inner):
file
function bool UGatherTextFromAssetsCommandlet::ParseCommandLineHelper
Source code excerpt:
{
bool bHasFailedToPreloadAnyModules = false;
for (const FString& ModuleName : ModulesToPreload)
{
EModuleLoadResult ModuleLoadResult;
FModuleManager::Get().LoadModuleWithFailureReason(*ModuleName, ModuleLoadResult);
if (ModuleLoadResult != EModuleLoadResult::Success)
{
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Commandlets/GatherTextFromAssetsCommandlet.cpp:1465
Scope (from outer to inner):
file
function bool UGatherTextFromAssetsCommandlet::ConfigureFromScript
Source code excerpt:
// Modules to Preload
GetStringArrayFromConfig(*SectionName, TEXT("ModulesToPreload"), ModulesToPreload, GatherTextConfigPath);
// IncludePathFilters
GetPathArrayFromConfig(*SectionName, TEXT("IncludePathFilters"), IncludePathFilters, GatherTextConfigPath);
// IncludePaths (DEPRECATED)
{
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Commandlets/GatherTextFromMetadataCommandlet.cpp:80
Scope (from outer to inner):
file
function int32 UGatherTextFromMetaDataCommandlet::Main
Source code excerpt:
//Modules to Preload
TArray<FString> ModulesToPreload;
GetStringArrayFromConfig(*SectionName, TEXT("ModulesToPreload"), ModulesToPreload, GatherTextConfigPath);
for (const FString& ModuleName : ModulesToPreload)
{
FModuleManager::Get().LoadModule(*ModuleName);
}
// IncludePathFilters
TArray<FString> IncludePathFilters;