PrimaryAssetTypesToScan

PrimaryAssetTypesToScan

#Overview

name: PrimaryAssetTypesToScan

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

It is referenced in 6 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of PrimaryAssetTypesToScan is to define a list of asset types that should be scanned at startup by the Asset Manager system in Unreal Engine 5. This variable is crucial for managing and organizing game assets efficiently.

The Unreal Engine subsystems and modules that rely on this setting variable are:

  1. Asset Manager system
  2. Game Features subsystem
  3. Game Features Editor module

The value of this variable is set in multiple places:

  1. In the AssetManagerSettings class as a configurable property
  2. In the GameFeatureData class as an editable property
  3. It can be modified programmatically through the AddDefaultGameDataRule function in the GameFeaturesEditorModule

PrimaryAssetTypesToScan interacts with other variables and systems, such as:

  1. FPrimaryAssetTypeInfo structures, which define the details of each asset type to scan
  2. AssetManager’s scanning and initialization processes
  3. GameFeatureData’s asset management functionality

Developers must be aware of the following when using this variable:

  1. It affects startup performance, as scanning assets takes time
  2. Changes to this variable require reinitialization of the Asset Manager
  3. It’s crucial for proper organization and management of game assets

Best practices when using this variable include:

  1. Only include necessary asset types to minimize startup time
  2. Ensure consistency between project-wide settings and GameFeatureData settings
  3. Use the Game Features Editor module to add or modify asset types when appropriate
  4. Consider the impact on build sizes and runtime memory when adding new asset types to scan
  5. Regularly review and optimize the list of asset types to scan as the project evolves

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseGame.ini:222, section: [/Script/Engine.AssetManagerSettings]

Location: <Workspace>/Engine/Config/BaseGame.ini:231, section: [/Script/Engine.AssetManagerSettings]

Location: <Workspace>/Engine/Config/BaseGame.ini:232, section: [/Script/Engine.AssetManagerSettings]

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

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

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

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

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

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

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

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

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

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

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/Runtime/GameFeatures/Source/GameFeatures/Private/GameFeaturesSubsystem.cpp:561

Scope (from outer to inner):

file
function     void UGameFeaturesSubsystem::AddGameFeatureToAssetManager

Source code excerpt:


			// If we did not previously scan anything for a primary asset type that is in our config, try to reuse the cook rules from the config instead of the one in the gamefeaturedata, which should not be modifying cook rules
			const FPrimaryAssetTypeInfo* ConfigTypeInfo = LocalAssetManager.GetSettings().PrimaryAssetTypesToScan.FindByPredicate([&TypeInfo](const FPrimaryAssetTypeInfo& PATI) -> bool { return PATI.PrimaryAssetType == TypeInfo.PrimaryAssetType; });
			if (ConfigTypeInfo)
			{
				LocalAssetManager.SetPrimaryAssetTypeRules(TypeInfo.PrimaryAssetType, ConfigTypeInfo->Rules);
			}
			else
			{

#Loc: <Workspace>/Engine/Plugins/Runtime/GameFeatures/Source/GameFeatures/Public/GameFeatureData.h:21

Scope (from outer to inner):

file
class        class UGameFeatureData : public UPrimaryDataAsset
function     virtual const TArray<FPrimaryAssetTypeInfo>& GetPrimaryAssetTypesToScan

Source code excerpt:

public:
	/** Method to get where the primary assets should scanned from in the plugin hierarchy */
	virtual const TArray<FPrimaryAssetTypeInfo>& GetPrimaryAssetTypesToScan() const { return PrimaryAssetTypesToScan; }

#if WITH_EDITOR
	virtual TArray<FPrimaryAssetTypeInfo>& GetPrimaryAssetTypesToScan() { return PrimaryAssetTypesToScan; }
	virtual void GetAssetRegistryTags(FAssetRegistryTagsContext Context) const override;
	static void GetDependencyDirectoriesFromAssetData(const FAssetData& AssetData, TArray<FString>& OutDependencyDirectories);

	//~Begin deprecation
	UE_DEPRECATED(5.4, "Implement the version that takes FAssetRegistryTagsContext instead.")
	virtual void GetAssetRegistryTags(TArray<FAssetRegistryTag>& OutTags) const override;

#Loc: <Workspace>/Engine/Plugins/Runtime/GameFeatures/Source/GameFeatures/Public/GameFeatureData.h:101

Scope (from outer to inner):

file
class        class UGameFeatureData : public UPrimaryDataAsset

Source code excerpt:

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

#if UE_ENABLE_INCLUDE_ORDER_DEPRECATED_IN_5_2
#include "CoreMinimal.h"
#include "Engine/AssetManagerTypes.h"
#endif

#Loc: <Workspace>/Engine/Plugins/Runtime/GameFeatures/Source/GameFeaturesEditor/Private/GameFeaturesEditorModule.cpp:350

Scope (from outer to inner):

file
class        class FGameFeaturesEditorModule : public FDefaultModuleImpl
function     void AddDefaultGameDataRule

Source code excerpt:

			Settings->Modify(true);

			Settings->PrimaryAssetTypesToScan.Add(NewTypeInfo);

 			Settings->PostEditChange();
			Settings->TryUpdateDefaultConfigFile();

			UAssetManager::Get().ReinitializeFromConfig();
		}

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

Scope (from outer to inner):

file
class        class UAssetManagerSettings : public UDeveloperSettings

Source code excerpt:

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

	/** List of directories to exclude from scanning for Primary Assets, useful to exclude test assets */
	UPROPERTY(config, EditAnywhere, Category = "Asset Manager", meta = (RelativeToGameContentDir, LongPackageName))
	TArray<FDirectoryPath> DirectoriesToExclude;

	/** List of specific asset rule overrides */

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

Scope (from outer to inner):

file
function     void UAssetManager::ScanPrimaryAssetTypesFromConfig

Source code excerpt:


	double LastPumpTime = FPlatformTime::Seconds();
	for (FPrimaryAssetTypeInfo TypeInfo : Settings.PrimaryAssetTypesToScan)
	{
		// This function also fills out runtime data on the copy
		if (!ShouldScanPrimaryAssetType(TypeInfo))
		{
			continue;
		}